Skip to content

Commit dcfa9cb

Browse files
committed
Fix handling of Xcode projects with quotes in their path and scheme names. Closes #730
1 parent 4ee3b43 commit dcfa9cb

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
##### Bug Fixes
1212

1313
- Unused parameter warnings are suppressed in `@available(*, unavailable)` functions.
14+
- Fix handling of Xcode projects with single and double quotes in their path and scheme names.
1415

1516
## 3.0.3 (2025-03-15)
1617

Sources/Extensions/String+Extension.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ public extension String {
3232
@inlinable var djb2Hex: String {
3333
String(format: "%02x", djb2)
3434
}
35+
36+
@inlinable var withEscapedQuotes: String {
37+
replacingOccurrences(of: "\"", with: "\\\"")
38+
}
3539
}

Sources/XcodeSupport/XcodeProjectSetupGuide.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ public final class XcodeProjectSetupGuide: SetupGuideHelpers, SetupGuide {
117117
var options: [String] = []
118118

119119
if let project = configuration.project {
120-
options.append("--project \"\(project)\"")
120+
options.append("--project \"\(project.string.withEscapedQuotes)\"")
121121
}
122122

123-
options.append("--schemes " + configuration.schemes.map { "\"\($0)\"" }.joined(separator: ","))
123+
options.append("--schemes " + configuration.schemes.map { "\"\($0.withEscapedQuotes)\"" }.joined(separator: ","))
124124

125125
if configuration.retainObjcAccessible {
126126
options.append("--retain-objc-accessible")

Sources/XcodeSupport/Xcodebuild.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public final class Xcodebuild {
3535
@discardableResult
3636
public func build(project: XcodeProjectlike, scheme: String, allSchemes: [String], additionalArguments: [String] = []) throws -> String {
3737
let args = try [
38-
"-\(project.type)", "'\(project.path.lexicallyNormalized().string)'",
39-
"-scheme", "'\(scheme)'",
38+
"-\(project.type)", "\"\(project.path.lexicallyNormalized().string.withEscapedQuotes)\"",
39+
"-scheme", "\"\(scheme.withEscapedQuotes)\"",
4040
"-parallelizeTargets",
4141
"-derivedDataPath", "'\(derivedDataPath(for: project, schemes: allSchemes).string)'",
4242
"-quiet",
@@ -79,7 +79,7 @@ public final class Xcodebuild {
7979

8080
func schemes(type: String, path: String, additionalArguments: [String]) throws -> Set<String> {
8181
let args = [
82-
"-\(type)", "'\(path)'",
82+
"-\(type)", "\"\(path.withEscapedQuotes)\"",
8383
"-list",
8484
"-json",
8585
]

baselines/linux.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"v1":{"usrs":["import-Configuration-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:2:5","import-Indexer-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:4:5","import-Logger-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:5:5","import-Shared-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:6:5","import-SourceGraph-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:7:5","import-TestShared-Tests\/PeripheryTests\/ObjcAccessibleRetentionTest.swift:2:1","import-TestShared-Tests\/PeripheryTests\/ObjcAnnotatedRetentionTest.swift:2:1","s:11SourceGraph15ProjectFileKindO10extensionsSaySSGvp","s:6Shared14SetupSelectionO","s:6Shared17SetupGuideHelpersC6select8multipleAA0B9SelectionOSaySSG_tF","s:SS10ExtensionsE4djb2Sivp","s:SS10ExtensionsE7djb2HexSSvp"]}}
1+
{"v1":{"usrs":["import-Configuration-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:2:5","import-Indexer-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:4:5","import-Logger-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:5:5","import-Shared-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:6:5","import-SourceGraph-Sources\/ProjectDrivers\/XcodeProjectDriver.swift:7:5","import-TestShared-Tests\/PeripheryTests\/ObjcAccessibleRetentionTest.swift:2:1","import-TestShared-Tests\/PeripheryTests\/ObjcAnnotatedRetentionTest.swift:2:1","s:11SourceGraph15ProjectFileKindO10extensionsSaySSGvp","s:6Shared14SetupSelectionO","s:6Shared17SetupGuideHelpersC6select8multipleAA0B9SelectionOSaySSG_tF","s:SS10ExtensionsE17withEscapedQuotesSSvp","s:SS10ExtensionsE4djb2Sivp","s:SS10ExtensionsE7djb2HexSSvp"]}}

0 commit comments

Comments
 (0)