Skip to content

Commit f1ae066

Browse files
authored
fix plugin's path escaping on Darwin (#1989)
A port of grpc/grpc-swift#2273 to fix the same issue here.
1 parent 571f230 commit f1ae066

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Plugins/SwiftProtobufPlugin/plugin.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ struct SwiftProtobufPlugin {
179179
) -> Command {
180180
// Construct the `protoc` arguments.
181181
var protocArgs = [
182-
"--plugin=protoc-gen-swift=\(protocGenSwiftPath.path())",
183-
"--swift_out=\(outputDirectory.path())",
182+
"--plugin=protoc-gen-swift=\(protocGenSwiftPath.fileSystemPath)",
183+
"--swift_out=\(outputDirectory.fileSystemPath)",
184184
]
185185

186186
let protoDirectory =
@@ -191,7 +191,7 @@ struct SwiftProtobufPlugin {
191191
}
192192

193193
protocArgs.append("-I")
194-
protocArgs.append(protoDirectory.path())
194+
protocArgs.append(protoDirectory.fileSystemPath)
195195

196196
// Add the visibility if it was set
197197
if let visibility = invocation.visibility {
@@ -272,6 +272,16 @@ extension SwiftProtobufPlugin: BuildToolPlugin {
272272
}
273273
}
274274

275+
extension URL {
276+
fileprivate var fileSystemPath: String {
277+
#if canImport(Darwin)
278+
return self.path(percentEncoded: false)
279+
#else
280+
return self.path()
281+
#endif
282+
}
283+
}
284+
275285
#if canImport(XcodeProjectPlugin)
276286
import XcodeProjectPlugin
277287

0 commit comments

Comments
 (0)