Skip to content

Commit

Permalink
Add --legacy flag for Xcode 16 compatibility (#88)
Browse files Browse the repository at this point in the history
* Temporary fix for Xcode 16

* Short term fix for Xcode 16

* Add --legacy flag to graph as well

* Conditionally add legacy flag
  • Loading branch information
marinofelipe authored Oct 24, 2024
1 parent 7660b56 commit b1f5fb7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/XCParseCore/Version+XCPTooling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public extension Version {
return Version(15500, 0, 0)
}

static func xcresulttoolWithDeprecatedAPIs() -> Version {
return Version(23028, 0, 0)
}

static func xcresulttool() -> Version? {
guard let xcresulttoolVersionResult = XCResultToolCommand.Version().run() else {
return nil
Expand Down
25 changes: 25 additions & 0 deletions Sources/XCParseCore/XCResultToolCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ open class XCResultToolCommand {
"--path", xcresult.path,
"--id", self.id,
"--output-path", self.outputPath])
processArgs.addLegacyFlagIfNeeded()

let process = TSCBasic.Process(arguments: processArgs)
super.init(withXCResult: xcresult, process: process)
Expand All @@ -97,6 +98,8 @@ open class XCResultToolCommand {
"--id", self.id,
"--output-path", self.outputPath])

processArgs.addLegacyFlagIfNeeded()

let process = TSCBasic.Process(arguments: processArgs)
super.init(withXCResult: xcresult, process: process)
}
Expand Down Expand Up @@ -127,6 +130,7 @@ open class XCResultToolCommand {
if self.outputPath != "" {
processArgs.append(contentsOf: ["--output-path", self.outputPath])
}
processArgs.addLegacyFlagIfNeeded()

let process = TSCBasic.Process(arguments: processArgs)
super.init(withXCResult: xcresult, process: process)
Expand All @@ -150,6 +154,7 @@ open class XCResultToolCommand {
if let version = self.version {
processArgs.append(contentsOf: ["--version", "\(version)"])
}
processArgs.addLegacyFlagIfNeeded()

let process = TSCBasic.Process(arguments: processArgs)
super.init(withXCResult: xcresult, process: process)
Expand Down Expand Up @@ -180,3 +185,23 @@ open class XCResultToolCommand {
}
}
}

// MARK: - Legacy flag

private let shouldAddLegacyFlag: Bool = {
guard let xcresulttoolVersion = Version.xcresulttool() else {
return false
}

let versionWithDeprecatedAPIs = Version.xcresulttoolWithDeprecatedAPIs()

return xcresulttoolVersion >= versionWithDeprecatedAPIs
}()

private extension Array where Element: StringProtocol {
mutating func addLegacyFlagIfNeeded() {
if shouldAddLegacyFlag {
self.append("--legacy")
}
}
}

0 comments on commit b1f5fb7

Please sign in to comment.