react-native-firebase
react-native-firebase copied to clipboard
[🐛] After configuring RNFirebase for iOS, i get error RCTBridgeDelegate.h' file not found
🔥 Hi there,
Issue
After configuring RNFirebase to my React Native project, I get the following error: RCTBridgeDelegate.h' file not found
. I have applied the suggested configuration as stated in the docs: click here.
Project Files
My Podfile looks like this:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/@nrwl/react-native/nx_post_install'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
$RNFirebaseAsStaticFramework = true
target 'Mobile' do
use_frameworks!
use_modular_headers!
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false,
:fabric_enabled => false,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
nx_post_install(installer)
end
end
This is my AppDelegate.mm file
#import "AppDelegate.h"
#import "Firebase.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTAppSetupUtils.h>
#import "RNBootSplash.h"
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
RCTAppSetupPrepareApp(application);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
#if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"Mobile", nil);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"apps/mobile/src/main"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
#if RCT_NEW_ARCH_ENABLED
#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}
#pragma mark RCTTurboModuleManagerDelegate
- (Class)getModuleClassFromName:(const char *)name
{
return RCTCoreModulesClassProvider(name);
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return nullptr;
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
#endif
@end
Details
I have explicitly disabled hermes and flipper. New_architecture should be disabled as well according to the docs, but I don't believe I am using this currently.
I have tried the following steps to reproduce:
- Deleting the
build
, andPods
folder, and thenpod install
- Run
pod deintegrate
, andpod install
-
sudo arch -x86_64 gem install ffi
, and then in iOS:arch -x86_64 pod install
I use the following versions:
- "@react-native-firebase/app": "^15.1.1",
- "@react-native-firebase/messaging": "^15.1.1",
I hope anyone is able to help me with this issue. Thanks in advance! :)
As a stopgap you may want to use v14 here for now, and remove the use_frameworks stuff, that's the typical cause.
I hate to see the arch -x86_64
stuff but I understand the FFI area is still problematic? Or it was until recently. Not sure what problems that could cause though
For react-native-firebase v15 I do provide this in order to show a comparison between "project that builds" and "whatever is wrong with my project" - https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh since there are so many ways things can go wrong
I wonder if you reintroduce your project's differences to the result of that demo if things start working ? Or you are able to determine the problem area?
Sorry for the late reply, we live in different time zones i believe. I have tested v14, without the use_frameworks stuff, which gives me errors related to the modules 'fmt' and 'folly'. I believe these were known errors, which were supposed to be solved with use_frameworks
, but I'm not sure..
apps/mobile/ios/Pods/Headers/Public/fmt/fmt.modulemap:1:8: error: redefinition of module 'fmt' module fmt {
apps/mobile/ios/Pods/Headers/Public/folly/RCT-Folly.modulemap:1:8: error: redefinition of module 'folly' module folly {
Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.
Hi !
I found this workaround : https://stackoverflow.com/a/73092662 I was able to compile the app on iOs and android, hope this will help.
@NicolasTA-webagency can you so full step for your solution? I can't do pod install with
"react": "18.0.0",
"react-native": "0.69.2",
"@react-native-firebase/app": "^15.2.0",
@nighttiger1990 After follow the instructions for installation, i don't do this step : https://rnfirebase.io/#altering-cocoapods-to-use-frameworks
Instead of that, I put this lines in my Podfile, just before the use_react_native! :
# Firebase
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'FirebaseStorageInternal', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'FirebaseMessagingInterop', :modular_headers => true
pod 'GTMSessionFetcher', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
I still use native_modules! and flipper
I use Realtime Database for a couple of days now and it works like a charm.
Here is the full Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
production = ENV["PRODUCTION"] == "1"
target 'FirebaseTest' do
config = use_native_modules!
flags = get_default_flags()
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'FirebaseStorageInternal', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'FirebaseMessagingInterop', :modular_headers => true
pod 'GTMSessionFetcher', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:production => production,
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
:flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'FirebaseTestTests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Here is the full Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false production = ENV["PRODUCTION"] == "1" target 'FirebaseTest' do config = use_native_modules! flags = get_default_flags() pod 'Firebase', :modular_headers => true pod 'FirebaseCore', :modular_headers => true pod 'FirebaseCoreInternal', :modular_headers => true pod 'FirebaseStorageInternal', :modular_headers => true pod 'FirebaseCoreExtension', :modular_headers => true pod 'FirebaseAppCheckInterop', :modular_headers => true pod 'FirebaseAuthInterop', :modular_headers => true pod 'FirebaseMessagingInterop', :modular_headers => true pod 'GTMSessionFetcher', :modular_headers => true pod 'FirebaseAppCheckInterop', :modular_headers => true pod 'FirebaseAuthInterop', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy" pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse" use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :production => production, :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :flipper_configuration => FlipperConfiguration.enabled, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'FirebaseTestTests' do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end
You. I love you. This solved my 4 days worth of headaches. Thank you so so much.
This isn't going to work in the future though, firebase-ios-sdk requires use_frameworks!
and that is not going to change. So we have to require it. So react-native (and Flipper) need to support it. Anything else is a possibly-functional-right-now workaround (and great if you found it and it's working for you...) but cannot be officially supported and will fail over time as more and more firebase-ios-sdk modules strictly require use_frameworks
.
So the real solution if this is important to you and you have iOS skills is to help the react-native + flipper folks get use_frameworks!
working on iOS with Flipper. This may already be partially done with react-native 0.69.3 via https://github.com/facebook/react-native/pull/34214 which was picked into that release
Any updates on this? Facing the same issue. We've removed firebase and it's config for now since it's only used for cloud messaging in our app
@NicolasTA-webagency
the per mission path you have added is it same for all / why it should be added?
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
https://stackoverflow.com/a/73092662
thank you, this solved my problems
@hungnm11 that did not solve your problems, it only postponed them a tiny amount, and will give you other problems if you use Storage or Functions now. Avoiding the use of use_frameworks
is a dead-end solution and I must repeat that to every user that tries it. You need to use use_frameworks! :linkage => :static
to use firebase-ios-sdk v9+ and that's it. Nothing else is supportable.
Until Flipper is ready, you will have to avoid Flipper, and the onus is on us (as interested Flipper users) to contribute to the solution there by collaborating with + mentioning interest in it to the Flipper team.
Is there anyway to fix this without removing use_frameworks? I can run the app through react native cli, but I can't compile in Xcode.
Here is the pod file:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
target 'CampusConnect' do
use_frameworks! :linkage => :static
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => FlipperConfiguration.disabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'CampusConnectTests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
#Fix bug where headers get set as "Project" files instead of "Public" when cocoapods traverses symlinks
installer.pods_project.targets.each do |target|
puts "target ? #{target.name}"
if (target.respond_to?(:headers_build_phase) && target.name.include?("React-bridging"))
puts "target has headers build phase, setting public attrs"
target.headers_build_phase.files.each do |file|
puts "setting attributes on header build phase #{file.file_ref.name}"
file.settings = { 'ATTRIBUTES' => ['Public'] }
end
end
#Fix search paths for React-bridging
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
target_installation_result.native_target.build_configurations.each do |config|
# For third party modules who have React-bridging dependency to search correct headers
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging" '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/_.framework/Headers" '
end
end
# @generated end rn-firebase-use-frameworks-hacks-header-paths
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end
end
:fabric_enabled => flags[:fabric_enabled],
Maybe just make that false?
#Fix search paths for React-bridging
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
target_installation_result.native_target.build_configurations.each do |config|
# For third party modules who have React-bridging dependency to search correct headers
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging" '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/_.framework/Headers" '
end
end
...that section is strange to me. I don't need that. My build demo doesn't need that :thinking: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh
I actually figured out I was just opening the wrong file in Xcode 🤦. You have to open the .xcworkspace file and not the .xcodeproj file.... Sorry, I'm really new to react native.
I've removed all the extra stuff from my Podfile and everything works now. 👍
I think that is probably the root cause of all this stuff at the moment. Definitely must open xcworkspace file if you have a cocoapod-integrated project (which is all react-native projects). I'm going to close this as there does not seem to be anything actionable here
Good luck with your projects, all
I was having the exact same issue and finally tracked it down.
- Change from
@include Firebase
to#include 'Firebase.h'
- Remove all
OTHER_CPP
flags (particularly the-fmodules
and-fcc-modules
flags) - Remove Pods directory
- run
pod install
- open workspace file