diff --git a/packages/react-native/scripts/ios-prebuild.js b/packages/react-native/scripts/ios-prebuild.js index 3160df83255..0e71fea00d8 100644 --- a/packages/react-native/scripts/ios-prebuild.js +++ b/packages/react-native/scripts/ios-prebuild.js @@ -68,9 +68,11 @@ async function main() { } // GENERATE XCFrameworks - const productsFolder = computeProductsFolder(outputFolder); - const frameworkPaths = computeFrameworkPaths(productsFolder); - buildXCFrameworks(root, buildFolder, frameworkPaths, buildType); + if (cli.tasks.compose) { + const productsFolder = computeProductsFolder(outputFolder); + const frameworkPaths = computeFrameworkPaths(productsFolder); + buildXCFrameworks(root, buildFolder, frameworkPaths, buildType); + } // Done! prebuildLog('🏁 Done!'); diff --git a/packages/react-native/scripts/ios-prebuild/xcframework.js b/packages/react-native/scripts/ios-prebuild/xcframework.js index 971d3ff250b..b86068e00f9 100644 --- a/packages/react-native/scripts/ios-prebuild/xcframework.js +++ b/packages/react-native/scripts/ios-prebuild/xcframework.js @@ -74,7 +74,7 @@ function buildXCFrameworks( buildFolder /*: string */, frameworkFolders /*: Array */, buildType /*: 'debug' | 'release' */, -) /*: Array */ { +) { const outputPath = path.join( buildFolder, 'output', @@ -86,25 +86,26 @@ function buildXCFrameworks( cleanPlatformFolders(outputPath); // Build the XCFrameworks by using each framework folder as input - const frameworks = frameworkFolders.map(frameworkFolder => { - const buildCommand = `xcodebuild -create-xcframework -framework "${frameworkFolder}" -output ${outputPath} -allow-internal-distribution`; - frameworkLog(`Building ${frameworkFolder}...`); + const frameworks = frameworkFolders + .map(frameworkFolder => { + return `-framework "${frameworkFolder}"`; + }) + .join(' '); - frameworkLog(buildCommand); - try { - execSync(buildCommand, { - cwd: rootFolder, - stdio: 'inherit', - }); - } catch (error) { - frameworkLog( - `Error building XCFramework: ${error.message}. Check if the build was successful.`, - 'warning', - ); - } + const buildCommand = `xcodebuild -create-xcframework ${frameworks} -output ${outputPath} -allow-internal-distribution`; - return outputPath; - }); + frameworkLog(buildCommand); + try { + execSync(buildCommand, { + cwd: rootFolder, + stdio: 'inherit', + }); + } catch (error) { + frameworkLog( + `Error building XCFramework: ${error.message}. Check if the build was successful.`, + 'warning', + ); + } // Copy header files from the headers folder that we used to build the swift package const outputHeaderFiles = copyHeaderFiles( @@ -121,8 +122,6 @@ function buildXCFrameworks( // Create the module map file createModuleMapFile(outputPath, umbrellaHeaderFile); - - return frameworks; } function copyHeaderFiles(