From e23d7106d575578df825eb3d4e3aef3ec15e909f Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 6 Mar 2025 12:04:23 -0800 Subject: [PATCH] Add function to sign XCFramework (#49863) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49863 After the creation of the XCFramework, that needs to be signed. After the XCFramework is signed, no further modification can happen or they would break the signature. ## Changelog: [Internal] - Add function to sign the XCFramework Reviewed By: cortinico Differential Revision: D70697279 fbshipit-source-id: c2411ca7d12d4679ba55f124cbb445367b15945a --- scripts/releases/ios-prebuild/cli.js | 8 ++++++++ scripts/releases/ios-prebuild/compose-framework.js | 14 ++++++++++++++ scripts/releases/prepare-ios-prebuilds.js | 1 + 3 files changed, 23 insertions(+) diff --git a/scripts/releases/ios-prebuild/cli.js b/scripts/releases/ios-prebuild/cli.js index f01007ed17e..aae4cd94741 100644 --- a/scripts/releases/ios-prebuild/cli.js +++ b/scripts/releases/ios-prebuild/cli.js @@ -75,6 +75,12 @@ const cli = yargs default: 'Debug', describe: 'Specify the configuration to build, Release or Debug (default).', }) + .option('identity', { + alias: 'i', + type: 'string', + describe: + 'Specify the code signing identity to use for signing the frameworks.', + }) .help(); /** @@ -90,6 +96,7 @@ async function getCLIConfiguration() /*: Promise, dependencies: $ReadOnlyArray, configuration: string, + identity: ?string, |}> */ { // Run input parsing const argv = await cli.argv; @@ -139,6 +146,7 @@ async function getCLIConfiguration() /*: Promise */, rootFolder /*: string */, buildFolder /*: string */, + identity /*: ?string */, ) { console.log('✅ Composing iOS XCFramework...'); @@ -71,6 +72,10 @@ async function createFramework( const symbolOutput = path.join(rootFolder, 'Symbols'); fs.mkdirSync(symbolOutput, {recursive: true}); symbolPaths.forEach(symbol => execSync(`cp -r ${symbol} ${symbolOutput}`)); + + if (identity) { + signXCFramework(identity, output); + } } /** @@ -131,4 +136,13 @@ function copyBundles( }); } +function signXCFramework( + identity /*: string */, + xcframeworkPath /*: string */, +) { + console.log('Signing XCFramework...'); + const command = `codesign --timestamp --sign "${identity}" ${xcframeworkPath}`; + execSync(command, {stdio: 'inherit'}); +} + module.exports = {createFramework}; diff --git a/scripts/releases/prepare-ios-prebuilds.js b/scripts/releases/prepare-ios-prebuilds.js index cfc716e56c7..37cef3a65cc 100644 --- a/scripts/releases/prepare-ios-prebuilds.js +++ b/scripts/releases/prepare-ios-prebuilds.js @@ -65,6 +65,7 @@ async function main() { cli.dependencies, rootFolder, buildFolder, + cli.identity, ); }