@@ -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