@@ -15,7 +15,11 @@ import {
1515 LinkModuleResult ,
1616 ModuleLinker ,
1717} from "./link-modules.js" ;
18- import { findXcodeProject } from "./xcode-helpers.js" ;
18+ import {
19+ determineFrameworkSlice ,
20+ ExpectedFrameworkSlice ,
21+ findXcodeProject ,
22+ } from "./xcode-helpers.js" ;
1923
2024const PACKAGE_ROOT = path . resolve ( __dirname , ".." , ".." , ".." ) ;
2125const CLI_PATH = path . resolve ( PACKAGE_ROOT , "bin" , "react-native-node-api.mjs" ) ;
@@ -408,10 +412,13 @@ export async function createAppleLinker(): Promise<ModuleLinker> {
408412 CODE_SIGNING_ALLOWED : signingAllowed ,
409413 } = process . env ;
410414
415+ const expectedSlice = determineFrameworkSlice ( ) ;
416+
411417 return ( options : LinkModuleOptions ) => {
412418 return linkXcframework ( {
413419 ...options ,
414420 outputPath,
421+ expectedSlice,
415422 signingIdentity :
416423 signingRequired !== "NO" && signingAllowed !== "NO"
417424 ? signingIdentity
@@ -420,74 +427,15 @@ export async function createAppleLinker(): Promise<ModuleLinker> {
420427 } ;
421428}
422429
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- */
429- export function determineFrameworkSlice ( ) : {
430- platform : string ;
431- platformVariant ?: string ;
432- architectures : string [ ] ;
433- } {
434- const {
435- PLATFORM_NAME : platformName ,
436- EFFECTIVE_PLATFORM_NAME : effectivePlatformName ,
437- ARCHS : architecturesJoined ,
438- } = process . env ;
439-
440- assert ( platformName , "Expected PLATFORM_NAME to be set by Xcodebuild" ) ;
441- assert ( architecturesJoined , "Expected ARCHS to be set by Xcodebuild" ) ;
442- const architectures = architecturesJoined . split ( " " ) ;
443-
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- ) ;
481- }
482- }
483-
484430export async function linkXcframework ( {
485431 modulePath,
486432 naming,
487433 outputPath : outputParentPath ,
434+ expectedSlice,
488435 signingIdentity,
489436} : LinkModuleOptions & {
490437 outputPath : string ;
438+ expectedSlice : ExpectedFrameworkSlice ;
491439 signingIdentity ?: string ;
492440} ) : Promise < LinkModuleResult > {
493441 // Copy the xcframework to the output directory and rename the framework and binary
@@ -500,8 +448,6 @@ export async function linkXcframework({
500448 await fs . promises . rm ( frameworkOutputPath , { recursive : true , force : true } ) ;
501449
502450 const info = await readXcframeworkInfo ( path . join ( modulePath , "Info.plist" ) ) ;
503-
504- const expectedSlice = determineFrameworkSlice ( ) ;
505451 const framework = info . AvailableLibraries . find ( ( framework ) => {
506452 return (
507453 expectedSlice . platform === framework . SupportedPlatform &&
0 commit comments