Skip to content

Commit b1f5fb7

Browse files
authored
Add --legacy flag for Xcode 16 compatibility (#88)
* Temporary fix for Xcode 16 * Short term fix for Xcode 16 * Add --legacy flag to graph as well * Conditionally add legacy flag
1 parent 7660b56 commit b1f5fb7

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Sources/XCParseCore/Version+XCPTooling.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public extension Version {
1313
return Version(15500, 0, 0)
1414
}
1515

16+
static func xcresulttoolWithDeprecatedAPIs() -> Version {
17+
return Version(23028, 0, 0)
18+
}
19+
1620
static func xcresulttool() -> Version? {
1721
guard let xcresulttoolVersionResult = XCResultToolCommand.Version().run() else {
1822
return nil

Sources/XCParseCore/XCResultToolCommand.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ open class XCResultToolCommand {
7575
"--path", xcresult.path,
7676
"--id", self.id,
7777
"--output-path", self.outputPath])
78+
processArgs.addLegacyFlagIfNeeded()
7879

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

101+
processArgs.addLegacyFlagIfNeeded()
102+
100103
let process = TSCBasic.Process(arguments: processArgs)
101104
super.init(withXCResult: xcresult, process: process)
102105
}
@@ -127,6 +130,7 @@ open class XCResultToolCommand {
127130
if self.outputPath != "" {
128131
processArgs.append(contentsOf: ["--output-path", self.outputPath])
129132
}
133+
processArgs.addLegacyFlagIfNeeded()
130134

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

154159
let process = TSCBasic.Process(arguments: processArgs)
155160
super.init(withXCResult: xcresult, process: process)
@@ -180,3 +185,23 @@ open class XCResultToolCommand {
180185
}
181186
}
182187
}
188+
189+
// MARK: - Legacy flag
190+
191+
private let shouldAddLegacyFlag: Bool = {
192+
guard let xcresulttoolVersion = Version.xcresulttool() else {
193+
return false
194+
}
195+
196+
let versionWithDeprecatedAPIs = Version.xcresulttoolWithDeprecatedAPIs()
197+
198+
return xcresulttoolVersion >= versionWithDeprecatedAPIs
199+
}()
200+
201+
private extension Array where Element: StringProtocol {
202+
mutating func addLegacyFlagIfNeeded() {
203+
if shouldAddLegacyFlag {
204+
self.append("--legacy")
205+
}
206+
}
207+
}

0 commit comments

Comments
 (0)