Properly setup headers for FBReactNativeSpec in prebuilds (#52783)

Summary:
bypass-github-export-checks
Pull Request resolved: https://github.com/facebook/react-native/pull/52783

This change reverts D78158734 which was a patch to make the dynamic frameworks work properly because we were not exporting the FBReactNativeSpec headers in prebuilds correctly.

This change fixes this, by exposritng those headers correctly.

[Internal] -

bypass-github-export-checks

Reviewed By: cortinico

Differential Revision: D78803425

fbshipit-source-id: 5613ed0c790455ea86668eeb436f7b78a0c80918
This commit is contained in:
Riccardo Cipolleschi
2025-07-29 10:02:29 +01:00
parent 67f507a53f
commit b00a91811e
4 changed files with 24 additions and 7 deletions
+4 -4
View File
@@ -23,7 +23,7 @@ jobs:
id: restore-ios-slice
uses: actions/cache/restore@v4
with:
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
path: packages/react-native/
- name: Setup node.js
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
@@ -117,7 +117,7 @@ jobs:
uses: actions/cache/save@v4
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
with:
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
path: |
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
packages/react-native/.build/headers
@@ -140,7 +140,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: packages/react-native/.build/output/xcframeworks
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
- name: Setup node.js
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-node
@@ -209,4 +209,4 @@ jobs:
path: |
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
@@ -18,7 +18,6 @@ end
header_search_paths = [
"\"${PODS_ROOT}/Headers/Public/ReactCodegen/react/renderer/components\"",
"\"${PODS_ROOT}/Headers/Public/React-RCTFBReactNativeSpec/FBReactNativeSpec\"",
]
Pod::Spec.new do |s|
@@ -46,7 +45,7 @@ Pod::Spec.new do |s|
s.dependency "React-Core/RCTPushNotificationHeaders"
s.dependency "React-jsi"
add_dependency(s, "React-RCTFBReactNativeSpec", :additional_framework_paths => ['FBReactNativeSpec'])
add_dependency(s, "React-RCTFBReactNativeSpec")
add_dependency(s, "ReactCommon", :subspec => "turbomodule/core", :additional_framework_paths => ["react/nativemodule/core"])
add_dependency(s, "React-NativeModulesApple")
+6
View File
@@ -10,6 +10,9 @@
/*:: import type {BuildFlavor} from './types'; */
const {
generateFBReactNativeSpecIOS,
} = require('../codegen/generate-artifacts-executor/generateFBReactNativeSpecIOS');
const {prepareHermesArtifactsAsync} = require('./hermes');
const {
prepareReactNativeDependenciesArtifactsAsync,
@@ -25,6 +28,9 @@ async function setup(
currentVersion /*: string */,
buildType /*: BuildFlavor */,
) {
// First of all, let's run codegen to make sure that we have the FBreactNativeSpec files in the prebuilds
generateFBReactNativeSpecIOS('.');
const prebuildLog = createLogger('prebuild');
createFolderIfNotExists(buildFolder);
+13 -1
View File
@@ -10,6 +10,9 @@
/*:: import type {BuildFlavor} from './types'; */
const {
generateFBReactNativeSpecIOS,
} = require('../codegen/generate-artifacts-executor/generateFBReactNativeSpecIOS');
const headers = require('./headers');
const utils = require('./utils');
const childProcess = require('child_process');
@@ -49,6 +52,9 @@ function buildXCFrameworks(
buildType /*: BuildFlavor */,
identity /*: ?string */,
) {
// Let's run codegen for FBReactNativeSpec otherwise some headers will be missing
generateFBReactNativeSpecIOS('.');
const outputPath = path.join(
buildFolder,
'output',
@@ -106,10 +112,16 @@ function buildXCFrameworks(
if (headerFiles.length > 0) {
// Get podspec name without directory and extension and make sure it is a valid identifier
// by replacing any non-alphanumeric characters with an underscore.
const podSpecName = path
let podSpecName = path
.basename(podspec, '.podspec')
.replace(/[^a-zA-Z0-9_]/g, '_');
// Fix for FBReactNativeSpec. RN expect FBReactNative spec headers
// To be in a folder named FBReactNativeSpec.
if (podSpecName === 'React_RCTFBReactNativeSpec') {
podSpecName = 'FBReactNativeSpec';
}
// Create a folder for the podspec in the output headers path
const podSpecFolder = path.join(outputHeadersPath, podSpecName);
createFolderIfNotExists(podSpecFolder);