Skip to content

Commit

Permalink
Quote additional arguments passed to xcodebuild/swift
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch committed Oct 30, 2023
1 parent 1ff2001 commit d73e64a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

- Fix redundant public accessibility analysis for protocol members declared in extensions that are referenced cross-module where the protocol itself is not.
- Remove checks causing errors when scanning multi-platform projects.
- Additional arguments passed through to xcodebuild/swift are now quoted automatically as needed.

## 2.16.0 (2023-09-27)

Expand Down
16 changes: 15 additions & 1 deletion Sources/XcodeSupport/Xcodebuild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ public final class Xcodebuild {
"INDEX_ENABLE_DATA_STORE=\"YES\""
]

let xcodebuild = "xcodebuild \((args + [cmd] + envs + additionalArguments).joined(separator: " "))"
// Apply quotes to additional option values is needed.
var quotedArguments = additionalArguments

for (i, arg) in additionalArguments.enumerated() {
if arg.hasPrefix("-"),
let value = additionalArguments[safe: i + 1],
!value.hasPrefix("-"),
!value.hasPrefix("\""),
!value.hasPrefix("\'")
{
quotedArguments[i + 1] = "\"\(value)\""
}
}

let xcodebuild = "xcodebuild \((args + [cmd] + envs + quotedArguments).joined(separator: " "))"
return try shell.exec(["/bin/sh", "-c", xcodebuild])
}

Expand Down

0 comments on commit d73e64a

Please sign in to comment.