Skip to content

Commit 0f26983

Browse files
authored
Merge pull request #245 from Resgrid/develop
RU-T50 Build fix
2 parents 5c9b3e7 + f3709c5 commit 0f26983

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

app.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
170170
ios: {
171171
deploymentTarget: '18.1',
172172
useFrameworks: 'static',
173+
// Build React Native from source instead of the prebuilt
174+
// ReactNativeDependencies.xcframework. The prebuilt core does not
175+
// re-export RN's preprocessor macros (RCT_EXTERN, RCT_CONCAT) across
176+
// the static-framework module boundary, so RCT_EXPORT_MODULE() fails
177+
// to compile in third-party Obj-C modules like @react-native-firebase.
178+
buildReactNativeFromSource: true,
173179
},
174180
},
175181
],

plugins/withWebRTCFrameworkFix.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ const path = require('path');
77
* compatibility with use_frameworks! :linkage => :static (required by
88
* @react-native-firebase).
99
*
10-
* Fixes three classes of errors:
10+
* Fixes four classes of errors:
1111
* 1. "include of non-modular header inside framework module" — sets
1212
* CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES for all pods.
1313
* 2. "declaration of 'X' must be imported from module 'Y' before it is required"
1414
* — adds use_modular_headers! so #import statements resolve correctly across
1515
* framework module boundaries.
1616
* 3. "RCTPromiseRejectBlock must be imported from module 'RNFBApp.RNFBAppModule'"
1717
* — patches RNFBMessaging source files to import RNFBAppModule explicitly.
18+
* 4. "unknown type name 'RCT_EXTERN'" / "duplicate declaration of method
19+
* 'RCT_CONCAT'" in RNFBMessagingModule.m (RCT_EXPORT_MODULE fails to expand)
20+
* — sets $RNFirebaseAsStaticFramework = true so the @react-native-firebase
21+
* pods build as static frameworks, letting React's macro headers resolve
22+
* inside the Firebase module.
1823
*/
1924
const withWebRTCFrameworkFix = (config) => {
2025
return withDangerousMod(config, [
@@ -23,6 +28,28 @@ const withWebRTCFrameworkFix = (config) => {
2328
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
2429
let contents = fs.readFileSync(podfilePath, 'utf-8');
2530

31+
// 0. Set $RNFirebaseAsStaticFramework = true at global scope (before any
32+
// target) so the @react-native-firebase pods build as static frameworks.
33+
// Without this, under use_frameworks! :linkage => :static the React
34+
// macro headers (RCT_EXTERN, RCT_CONCAT) don't resolve inside the
35+
// Firebase module and RCT_EXPORT_MODULE() fails to compile.
36+
if (!contents.includes('$RNFirebaseAsStaticFramework')) {
37+
const fbAnchor = 'prepare_react_native_project!';
38+
const fbAnchorIdx = contents.indexOf(fbAnchor);
39+
if (fbAnchorIdx === -1) {
40+
throw new Error(
41+
'[withWebRTCFrameworkFix] Could not find prepare_react_native_project! in Podfile — ' +
42+
'cannot place $RNFirebaseAsStaticFramework at global scope.'
43+
);
44+
}
45+
const fbEndOfLine = contents.indexOf('\n', fbAnchorIdx);
46+
const fbInsertAt = fbEndOfLine === -1 ? contents.length : fbEndOfLine + 1;
47+
contents =
48+
contents.slice(0, fbInsertAt) +
49+
'\n$RNFirebaseAsStaticFramework = true\n' +
50+
contents.slice(fbInsertAt);
51+
}
52+
2653
// 1. Add use_modular_headers! after use_frameworks! if not already present.
2754
if (!contents.includes('use_modular_headers!')) {
2855
const useFrameworksPattern = /use_frameworks!.*\n/g;

0 commit comments

Comments
 (0)