@@ -22,12 +22,27 @@ export const UNSUPPORTED_DARWIN_FOR_TRACED = 27;
2222/** Xcode 27 and above do not support traced extraction. */
2323export const UNSUPPORTED_XCODE_FOR_TRACED = 27 ;
2424
25+ /** Names of products that we check the versions of here. */
26+ type ProductName = "macOS" | "Xcode" | "Xcode SDK" ;
27+
2528/** A version along with the product it relates to. */
2629type ProductVersion = {
27- product : "macOS" | "Xcode" ;
30+ product : ProductName ;
2831 version : semver . SemVer ;
2932} ;
3033
34+ /** Gets the appropriate attribute name for the diagnostic based on {@link product}. */
35+ function diagnosticAttributeName ( product : ProductName ) : string {
36+ switch ( product ) {
37+ case "macOS" :
38+ return "darwinVersion" ;
39+ case "Xcode" :
40+ return "xcodeVersion" ;
41+ case "Xcode SDK" :
42+ return "xcodeSdkVersion" ;
43+ }
44+ }
45+
3146/**
3247 * Creates a diagnostic indicating that `version` of `product` is unsupported for traced analysis.
3348 * Depending on `skipUnsupportedTracedAnalysis`, this function then either throws a {@link ConfigurationError}
@@ -50,14 +65,17 @@ function handleUnsupportedVersion(
5065 const unsupportedVersion =
5166 product === "macOS"
5267 ? UNSUPPORTED_DARWIN_FOR_TRACED
53- : UNSUPPORTED_XCODE_FOR_TRACED ;
68+ : // We use the same constant for both Xcode and the Xcode SDK since we treat them
69+ // as equivalent indicators for whether traced analysis is unsupported.
70+ UNSUPPORTED_XCODE_FOR_TRACED ;
71+
5472 const baseMessage = [
5573 `Traced analysis is not supported on ${ product } ${ unsupportedVersion } or above.` ,
5674 `Configure your analysis to run on macOS ${ UNSUPPORTED_DARWIN_FOR_TRACED - 1 } or below` ,
5775 `and Xcode ${ UNSUPPORTED_XCODE_FOR_TRACED - 1 } or below.` ,
5876 ] . join ( " " ) ;
5977
60- const attributeName = product === "macOS" ? "darwinVersion" : "xcodeVersion" ;
78+ const attributeName = diagnosticAttributeName ( product ) ;
6179
6280 // Create a diagnostic that will show up on the TSP.
6381 for ( const language of tracedLanguages ) {
@@ -201,19 +219,30 @@ export async function checkRunnerSupportsTracedAnalysis(
201219 // incompatible, either is fine as we only check the major version below.
202220 const xcodeVer =
203221 xcodeVersionFromLink ( action . logger ) ??
204- ( await xcodeVersionFromXcodeBuild ( action . logger ) ) ??
205- ( await xcodeSdkVersion ( action . logger ) ) ;
222+ ( await xcodeVersionFromXcodeBuild ( action . logger ) ) ;
223+ let xcodeProduct : ProductVersion | undefined = undefined ;
224+
225+ if ( xcodeVer !== undefined ) {
226+ xcodeProduct = { product : "Xcode" , version : xcodeVer } ;
227+ } else {
228+ // Fallback to checking the SDK version, which may be available even if a full Xcode installation is not.
229+ const xcodeSdkVer = await xcodeSdkVersion ( action . logger ) ;
230+ xcodeProduct =
231+ xcodeSdkVer !== undefined
232+ ? { product : "Xcode SDK" , version : xcodeSdkVer }
233+ : undefined ;
234+ }
206235
207236 if (
208- xcodeVer !== undefined &&
209- xcodeVer . major >= UNSUPPORTED_XCODE_FOR_TRACED
237+ xcodeProduct !== undefined &&
238+ xcodeProduct . version . major >= UNSUPPORTED_XCODE_FOR_TRACED
210239 ) {
211240 handleUnsupportedVersion (
212241 action . logger ,
213242 config ,
214243 tracedLanguages ,
215244 abortUnsupportedTracedAnalysis ,
216- { product : "Xcode" , version : xcodeVer } ,
245+ xcodeProduct ,
217246 ) ;
218247 } else if ( xcodeVer === undefined ) {
219248 action . logger . info (
0 commit comments