Skip to content

Commit 0e6d93b

Browse files
authored
Remove percent-encoded chars in build plugin paths (#32)
### Motivation: Xcode provides paths to executables as strings referencing environment variables and then passes those strings to the build plugin as URLs. This meant that when we converted these URLs to strings they percent-encoded some characters and were no longer valid paths e.g. ``` /${BUILD_DIR}/${CONFIGURATION}/protoc-gen-swift ``` became ``` /$%7BBUILD_DIR%7D/$%7BCONFIGURATION%7D/protoc-gen-swift ``` ### Modifications: Have our utility function for accessing absolute paths as strings strip percent-encoding. ### Result: The build plugin works in Xcode
1 parent b036851 commit 0e6d93b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Plugins/PluginsShared/PluginUtils.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ func constructProtocGenGRPCSwiftArguments(
109109

110110
extension URL {
111111
/// Returns `URL.absoluteString` with the `file://` scheme prefix removed
112+
///
113+
/// Note: This method also removes percent-encoded UTF-8 characters
112114
var absoluteStringNoScheme: String {
113-
var absoluteString = self.absoluteString
115+
var absoluteString = self.absoluteString.removingPercentEncoding ?? self.absoluteString
114116
absoluteString.trimPrefix("file://")
115117
return absoluteString
116118
}

0 commit comments

Comments
 (0)