Skip to content

Commit

Permalink
Support swiftc version invocation used in Xcode 16b3 and greater
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Kerber <[email protected]>
  • Loading branch information
erikkerber committed Jul 17, 2024
1 parent 768b430 commit 546dbc7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/swiftc_stub/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ error: Failed to parse DEVELOPER_DIR from '-sdk'. Using /usr/bin/swiftc.
// MARK: - Main

let args = CommandLine.arguments
if args.count == 2, args.last == "-v" {
// Xcode 16.0 Beta 3 began using "--version" over "-v". Support both.
if args.count == 2, args.last == "--version" || args.last == "-v" {
guard let path = ProcessInfo.processInfo.environment["PATH"] else {
fputs("error: PATH not set", stderr)
exit(1)
Expand All @@ -198,7 +199,8 @@ if args.count == 2, args.last == "-v" {
\(developerDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
"""

try exit(runSubProcess(executable: swiftcPath, args: ["-v"]))
// args.last allows passing in -v (Xcode < 16b3) and --version (>= 16b3)
try exit(runSubProcess(executable: swiftcPath, args: [args.last!]))
}

let (
Expand Down

0 comments on commit 546dbc7

Please sign in to comment.