@@ -420,6 +420,12 @@ export async function createAppleLinker(): Promise<ModuleLinker> {
420420 } ;
421421}
422422
423+ /**
424+ * Maps Xcode PLATFORM_NAME to SupportedPlatform / SupportedPlatformVariant
425+ * as used in xcframework Info.plist (e.g. hello.apple.node/Info.plist).
426+ * PLATFORM_NAME values: iphoneos, iphonesimulator, macosx, appletvos,
427+ * appletvsimulator, xros, xrsimulator.
428+ */
423429export function determineFrameworkSlice ( ) : {
424430 platform : string ;
425431 platformVariant ?: string ;
@@ -435,27 +441,44 @@ export function determineFrameworkSlice(): {
435441 assert ( architecturesJoined , "Expected ARCHS to be set by Xcodebuild" ) ;
436442 const architectures = architecturesJoined . split ( " " ) ;
437443
438- const simulator = platformName . endsWith ( "simulator" ) ;
439-
440- if ( platformName === "iphonesimulator" ) {
441- return {
442- platform : "ios" ,
443- platformVariant : simulator ? "simulator" : undefined ,
444- architectures,
445- } ;
446- } else if ( platformName === "macosx" ) {
447- return {
448- platform : "macos" ,
449- architectures,
450- platformVariant : effectivePlatformName ?. endsWith ( "maccatalyst" )
451- ? "maccatalyst"
452- : undefined ,
453- } ;
444+ switch ( platformName ) {
445+ case "iphoneos" :
446+ return { platform : "ios" , architectures } ;
447+ case "iphonesimulator" :
448+ return {
449+ platform : "ios" ,
450+ platformVariant : "simulator" ,
451+ architectures,
452+ } ;
453+ case "macosx" :
454+ return {
455+ platform : "macos" ,
456+ architectures,
457+ platformVariant : effectivePlatformName ?. endsWith ( "maccatalyst" )
458+ ? "maccatalyst"
459+ : undefined ,
460+ } ;
461+ case "appletvos" :
462+ return { platform : "tvos" , architectures } ;
463+ case "appletvsimulator" :
464+ return {
465+ platform : "tvos" ,
466+ platformVariant : "simulator" ,
467+ architectures,
468+ } ;
469+ case "xros" :
470+ return { platform : "xros" , architectures } ;
471+ case "xrsimulator" :
472+ return {
473+ platform : "xros" ,
474+ platformVariant : "simulator" ,
475+ architectures,
476+ } ;
477+ default :
478+ throw new Error (
479+ `Unsupported platform: ${ effectivePlatformName ?? platformName } ` ,
480+ ) ;
454481 }
455-
456- throw new Error (
457- `Unsupported platform: ${ effectivePlatformName ?? platformName } ` ,
458- ) ;
459482}
460483
461484export async function linkXcframework ( {
0 commit comments