mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add function to package the xcframework (#49434)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49434 This change adds a function to create the xcframework sarting from the various .framework's slice built before. ## Changelog: [Internal] - Add function to create the xcframework Reviewed By: cortinico Differential Revision: D69660662 fbshipit-source-id: f58034c75cce3d242910d0ec1512be28059771ca
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f05ebd5d9d
commit
69a4d32028
+2
-1
@@ -145,7 +145,8 @@ vendor/
|
||||
/packages/react-native/third-party/glog
|
||||
/packages/react-native/third-party/.swiftpm
|
||||
/packages/react-native/third-party/.build
|
||||
.patch
|
||||
fix_*.patch
|
||||
*.xcframework
|
||||
|
||||
# Visual Studio Code (config dir - if present, this merges user defined
|
||||
# workspace settings on top of react-native.code-workspace)
|
||||
|
||||
@@ -226,21 +226,49 @@ async function copyHeadersToFrameworks(
|
||||
});
|
||||
}
|
||||
|
||||
function composeXCFrameworks(
|
||||
thirdPartyFolder /*: string */,
|
||||
buildDestinationPath /*: string */,
|
||||
) {
|
||||
console.log('Composing XCFrameworks...');
|
||||
const frameworksFolder = path.join(buildDestinationPath, 'Build', 'Products');
|
||||
const frameworks = fs.readdirSync(frameworksFolder);
|
||||
const frameworkPaths = frameworks.map(framework =>
|
||||
path.join(
|
||||
frameworksFolder,
|
||||
framework,
|
||||
'PackageFrameworks',
|
||||
'ReactNativeDependencies.framework',
|
||||
),
|
||||
);
|
||||
const frameworksArgs = frameworkPaths
|
||||
.map(framework => `-framework ${framework}`)
|
||||
.join(' ');
|
||||
const command = `xcodebuild -create-xcframework ${frameworksArgs} -output ${path.join(thirdPartyFolder, 'ReactNativeDependencies.xcframework')}`;
|
||||
execSync(command, {stdio: 'inherit'});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('Starting iOS prebuilds preparation...');
|
||||
|
||||
const swiftPMFolder = path.join(process.cwd(), THIRD_PARTY_PATH);
|
||||
const buildDestinationPath = path.join(swiftPMFolder, BUILD_DESTINATION);
|
||||
const thirdPartyFolder = path.join(process.cwd(), THIRD_PARTY_PATH);
|
||||
const buildDestinationPath = path.join(thirdPartyFolder, BUILD_DESTINATION);
|
||||
|
||||
await Promise.all(dependencies.map(setupDependency));
|
||||
|
||||
await build(swiftPMFolder, buildDestinationPath);
|
||||
await build(thirdPartyFolder, buildDestinationPath);
|
||||
|
||||
await Promise.all(
|
||||
dependencies.map(dependency =>
|
||||
copyHeadersToFrameworks(dependency, swiftPMFolder, buildDestinationPath),
|
||||
copyHeadersToFrameworks(
|
||||
dependency,
|
||||
thirdPartyFolder,
|
||||
buildDestinationPath,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
composeXCFrameworks(thirdPartyFolder, buildDestinationPath);
|
||||
console.log('Done!');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user