@@ -4,7 +4,7 @@ import * as path from "node:path";
44import { URL , fileURLToPath } from "node:url" ;
55import { loadAppConfig } from "../scripts/appConfig.mjs" ;
66import { findFile , readTextFile , toVersionNumber } from "../scripts/helpers.js" ;
7- import { cp_r , mkdir_p } from "../scripts/utils/filesystem.mjs" ;
7+ import { cp_r , mkdir_p , rm_r } from "../scripts/utils/filesystem.mjs" ;
88import { generateAssetsCatalogs } from "./assetsCatalog.mjs" ;
99import { generateEntitlements } from "./entitlements.mjs" ;
1010import { generateInfoPlist } from "./infoPlist.mjs" ;
@@ -34,13 +34,23 @@ import {
3434
3535const SUPPORTED_PLATFORMS = [ "ios" , "macos" , "visionos" ] ;
3636
37+ /**
38+ * @param {string } platform
39+ * @returns {asserts platform is ApplePlatform }
40+ */
41+ function assertSupportedPlatform ( platform ) {
42+ if ( ! SUPPORTED_PLATFORMS . includes ( platform ) ) {
43+ throw new Error ( `Unsupported platform: ${ platform } ` ) ;
44+ }
45+ }
46+
3747/**
3848 * @param {string } projectRoot
3949 * @param {string } destination
4050 * @returns {void }
4151 */
4252function exportNodeBinaryPath ( projectRoot , destination , fs = nodefs ) {
43- const node = process . argv0 ;
53+ const node = process . argv [ 0 ] ;
4454 fs . writeFileSync (
4555 path . join ( projectRoot , ".xcode.env" ) ,
4656 `export NODE_BINARY='${ node } '\n`
@@ -99,7 +109,7 @@ function readPackageVersion(p, fs = nodefs) {
99109
100110/**
101111 * @param {string } projectRoot
102- * @param {ApplePlatform } targetPlatform
112+ * @param {string } targetPlatform
103113 * @param {JSONObject } options
104114 * @returns {ProjectConfiguration }
105115 */
@@ -109,9 +119,7 @@ export function generateProject(
109119 options ,
110120 fs = nodefs
111121) {
112- if ( ! SUPPORTED_PLATFORMS . includes ( targetPlatform ) ) {
113- throw new Error ( `Unsupported platform: ${ targetPlatform } ` ) ;
114- }
122+ assertSupportedPlatform ( targetPlatform ) ;
115123
116124 const appConfig = loadAppConfig ( projectRoot , fs ) ;
117125
@@ -134,15 +142,19 @@ export function generateProject(
134142 // Link source files
135143 const srcDirs = [ "ReactTestApp" , "ReactTestAppTests" , "ReactTestAppUITests" ] ;
136144 for ( const file of srcDirs ) {
137- fs . linkSync ( projectPath ( file , targetPlatform ) , destination ) ;
145+ const symlink = path . join ( destination , file ) ;
146+ if ( fs . existsSync ( symlink ) ) {
147+ rm_r ( symlink , fs ) ;
148+ }
149+ fs . symlinkSync ( projectPath ( file , targetPlatform ) , symlink ) ;
138150 }
139151
140152 // Shared code lives in `ios/ReactTestApp/`
141153 if ( targetPlatform !== "ios" ) {
142154 const shared = path . join ( destination , "Shared" ) ;
143155 if ( ! fs . existsSync ( shared ) ) {
144156 const source = new URL ( "ReactTestApp" , import . meta. url ) ;
145- fs . linkSync ( fileURLToPath ( source ) , shared ) ;
157+ fs . symlinkSync ( fileURLToPath ( source ) , shared ) ;
146158 }
147159 }
148160
@@ -168,8 +180,8 @@ export function generateProject(
168180
169181 /** @type {ProjectConfiguration } */
170182 const project = {
171- xcodeprojPath : xcodeprojDst ,
172- reactNativePath,
183+ xcodeprojPath : path . resolve ( xcodeprojDst ) ,
184+ reactNativePath : path . resolve ( reactNativePath ) ,
173185 reactNativeVersion,
174186 useNewArch,
175187 useBridgeless,
@@ -178,9 +190,7 @@ export function generateProject(
178190 uitestsBuildSettings : { } ,
179191 } ;
180192
181- if ( isObject ( platformConfig ) ) {
182- applyBuildSettings ( platformConfig , project , projectRoot , destination , fs ) ;
183- }
193+ applyBuildSettings ( platformConfig , project , projectRoot , destination , fs ) ;
184194
185195 const overrides = options [ "buildSettingOverrides" ] ;
186196 if ( isObject ( overrides ) ) {
0 commit comments