Skip to content

Commit 5976618

Browse files
authored
Properly setup headers for FBReactNativeSpec in prebuilds (#52783) (#52897)
Summary: bypass-github-export-checks Pull Request resolved: #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
1 parent 67f507a commit 5976618

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

.github/workflows/prebuild-ios-core.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
id: restore-ios-slice
2424
uses: actions/cache/restore@v4
2525
with:
26-
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
26+
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/**/*') }}
2727
path: packages/react-native/
2828
- name: Setup node.js
2929
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
@@ -117,7 +117,7 @@ jobs:
117117
uses: actions/cache/save@v4
118118
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
119119
with:
120-
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
120+
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/**/*') }}
121121
path: |
122122
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
123123
packages/react-native/.build/headers
@@ -140,7 +140,7 @@ jobs:
140140
uses: actions/cache/restore@v4
141141
with:
142142
path: packages/react-native/.build/output/xcframeworks
143-
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
143+
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/**/*') }}
144144
- name: Setup node.js
145145
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
146146
uses: ./.github/actions/setup-node
@@ -209,4 +209,4 @@ jobs:
209209
path: |
210210
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz
211211
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz
212-
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
212+
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/**/*') }}

packages/react-native/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ end
1818

1919
header_search_paths = [
2020
"\"${PODS_ROOT}/Headers/Public/ReactCodegen/react/renderer/components\"",
21-
"\"${PODS_ROOT}/Headers/Public/React-RCTFBReactNativeSpec/FBReactNativeSpec\"",
2221
]
2322

2423
Pod::Spec.new do |s|
@@ -46,7 +45,7 @@ Pod::Spec.new do |s|
4645
s.dependency "React-Core/RCTPushNotificationHeaders"
4746
s.dependency "React-jsi"
4847

49-
add_dependency(s, "React-RCTFBReactNativeSpec", :additional_framework_paths => ['FBReactNativeSpec'])
48+
add_dependency(s, "React-RCTFBReactNativeSpec")
5049
add_dependency(s, "ReactCommon", :subspec => "turbomodule/core", :additional_framework_paths => ["react/nativemodule/core"])
5150
add_dependency(s, "React-NativeModulesApple")
5251

packages/react-native/scripts/ios-prebuild/setup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
/*:: import type {BuildFlavor} from './types'; */
1212

13+
const {
14+
generateFBReactNativeSpecIOS,
15+
} = require('../codegen/generate-artifacts-executor/generateFBReactNativeSpecIOS');
1316
const {prepareHermesArtifactsAsync} = require('./hermes');
1417
const {
1518
prepareReactNativeDependenciesArtifactsAsync,
@@ -25,6 +28,9 @@ async function setup(
2528
currentVersion /*: string */,
2629
buildType /*: BuildFlavor */,
2730
) {
31+
// First of all, let's run codegen to make sure that we have the FBreactNativeSpec files in the prebuilds
32+
generateFBReactNativeSpecIOS('.');
33+
2834
const prebuildLog = createLogger('prebuild');
2935
createFolderIfNotExists(buildFolder);
3036

packages/react-native/scripts/ios-prebuild/xcframework.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
/*:: import type {BuildFlavor} from './types'; */
1212

13+
const {
14+
generateFBReactNativeSpecIOS,
15+
} = require('../codegen/generate-artifacts-executor/generateFBReactNativeSpecIOS');
1316
const headers = require('./headers');
1417
const utils = require('./utils');
1518
const childProcess = require('child_process');
@@ -49,6 +52,9 @@ function buildXCFrameworks(
4952
buildType /*: BuildFlavor */,
5053
identity /*: ?string */,
5154
) {
55+
// Let's run codegen for FBReactNativeSpec otherwise some headers will be missing
56+
generateFBReactNativeSpecIOS('.');
57+
5258
const outputPath = path.join(
5359
buildFolder,
5460
'output',
@@ -106,10 +112,16 @@ function buildXCFrameworks(
106112
if (headerFiles.length > 0) {
107113
// Get podspec name without directory and extension and make sure it is a valid identifier
108114
// by replacing any non-alphanumeric characters with an underscore.
109-
const podSpecName = path
115+
let podSpecName = path
110116
.basename(podspec, '.podspec')
111117
.replace(/[^a-zA-Z0-9_]/g, '_');
112118

119+
// Fix for FBReactNativeSpec. RN expect FBReactNative spec headers
120+
// To be in a folder named FBReactNativeSpec.
121+
if (podSpecName === 'React_RCTFBReactNativeSpec') {
122+
podSpecName = 'FBReactNativeSpec';
123+
}
124+
113125
// Create a folder for the podspec in the output headers path
114126
const podSpecFolder = path.join(outputHeadersPath, podSpecName);
115127
createFolderIfNotExists(podSpecFolder);

0 commit comments

Comments
 (0)