From 0e6d93b8aaf61270caffc4d6101a48de564b8f11 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Tue, 21 Jan 2025 17:48:40 +0000 Subject: [PATCH] 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 --- Plugins/PluginsShared/PluginUtils.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/PluginsShared/PluginUtils.swift b/Plugins/PluginsShared/PluginUtils.swift index 0fb3621..e85232a 100644 --- a/Plugins/PluginsShared/PluginUtils.swift +++ b/Plugins/PluginsShared/PluginUtils.swift @@ -109,8 +109,10 @@ func constructProtocGenGRPCSwiftArguments( extension URL { /// Returns `URL.absoluteString` with the `file://` scheme prefix removed + /// + /// Note: This method also removes percent-encoded UTF-8 characters var absoluteStringNoScheme: String { - var absoluteString = self.absoluteString + var absoluteString = self.absoluteString.removingPercentEncoding ?? self.absoluteString absoluteString.trimPrefix("file://") return absoluteString }