fix(ios): wire prebuilt React-Core and allow non-modular React imports for use_frameworks! (RN 0.84+) - #9129
Conversation
…s for use_frameworks! (RN 0.84+)
RN 0.83+ ships a prebuilt React-Core, enabled by default on 0.84+ via
RCT_USE_PREBUILT_RNCORE=1. Two problems break RNFB iOS builds:
1. Header resolution: the legacy <React/...> imports in RNFB's Objective-C
sources need the prebuilt React-Core wired via React Native's
add_rncore_dependency helper. Called here, guarded with defined? so older
react-native versions are unaffected.
2. Framework module validation: when a consumer builds with use_frameworks!
(Expo's default, and required by the firebase-ios-sdk), RNFB compiles as a
framework module and Clang rejects the non-modular <React/...> includes with
-Wnon-modular-include-in-framework-module ("must be imported from module
'React'"). Setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES=YES
lets the module validate.
The xcconfig is merged into any existing pod_target_xcconfig so per-package
settings (e.g. generated TurboModule header search paths) are preserved.
This removes the need for the RCT_USE_PREBUILT_RNCORE=0 workaround that forces
React-Core to be rebuilt from source.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Hey 👋 thanks for this - Quick note to say before we look at this, it is going to have to wait for the SPM support to land (it's reviewed+approved and just needs merge): ...which is itself waiting on v26 to launch (there will be a PR for some fixes there, it's about ready to go) So, hopefully not long, and it's our next priority to fix after SPM lands but it will probably be a conflict bonanza once SPM does land |
Thanks @mikehardy, makes sense to wait for SPM to land first. Happy to rebase and clean up the conflicts once it's in, just give me a shout. |
Description
React Native 0.83+ ships a prebuilt React-Core and enables it by default on 0.84+ (
RCT_USE_PREBUILT_RNCORE=1). This breaksreact-native-firebaseiOS builds in two ways:Header resolution — the legacy
<React/...>imports in RNFB's Objective-C sources (RCTConvert.h,RCTBridgeModule.h,RCTEventEmitter.h, …) need the prebuilt React-Core wired via React Native'sadd_rncore_dependencyhelper.Framework module validation — when a consumer builds with
use_frameworks!(Expo's default, and required by thefirebase-ios-sdk), each RNFB pod is compiled as a framework module. Clang then rejects the non-modular<React/...>includes with:Both are fixed here across all 16 package podspecs:
add_rncore_dependency(s), guarded withif defined?(...)so olderreact-nativeversions are unaffected.CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES, merged into any existingpod_target_xcconfigso per-package settings (e.g. generated TurboModule header search paths in analytics/auth/firestore/storage/etc.) are preserved rather than overwritten.Related
main; uses a non-destructive.mergeonpod_target_xcconfigto avoid clobbering the newer per-packageHEADER_SEARCH_PATHSentries.Effect for consumers
Removes the need for the common workarounds:
ENV['RCT_USE_PREBUILT_RNCORE'] = '0'(forces React-Core to rebuild from source — slow clean builds)expo-build-propertiesforceStaticLinkinglisting every RNFB packageTest plan
pod installwithuse_frameworks! :linkage => :static+$RNFirebaseAsStaticFramework = trueon RN 0.84.x, defaultRCT_USE_PREBUILT_RNCORE(prebuilt), New Architecture.@react-native-firebase/{app,analytics,crashlytics,messaging}— compiles without theRCT_USE_PREBUILT_RNCORE=0workaround.ruby -c) — passing.