I'm working on a React Native CLI project (iOS) and encountering a build error in Xcode: 'FirebaseAuth/FirebaseAuth-Swift.h' file not found. This issue occurs when trying to integrate Firebase Authentication into my project. Below are the details of my setup, code, and steps I've tried to resolve the issue.
Project Details
- React Native Version: [e.g., 0.74.5, replace with your actual version, check with npx react-native -v]
- @react-native-firebase/app: [e.g., 21.0.0, replace with your version from package.json]
- @react-native-firebase/auth: [e.g., 21.0.0, replace with your version from package.json]
- Xcode Version: [e.g., 15.4, replace with your version]
- macOS Version: [e.g., Ventura 13.5, replace with your version]
- CocoaPods Version: [e.g., 1.15.2, replace with pod --version]
- iOS Deployment Target: 13.0**
Relevant Code
ios/Podfile ruby
require Pod::Executable.execute_command('node', ['-p',
'require.resolve("react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]})',
__dir__
]).strip
platform :ios, '13.0'
use_modular_headers!
prepare_react_native_project!
rn_maps_path = '../node_modules/react-native-maps'
linkage = ENV['USE_FRAMEWORKS']
if linkage
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
target 'AwesomeProject' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => false,
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod 'react-native-maps', :path => rn_maps_path
# Firebase dependencies (manually added for clarity)
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseAuth', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
target 'AwesomeProjectTests' do
inherit! :complete
end
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
min_ios_version_supported = '13.0'
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = min_ios_version_supported
end
end
end
end
ios/AwesomeProject/AppDelegate.mm
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <GoogleMaps/GoogleMaps.h>
#import <Firebase.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[GMSServices provideAPIKey:@"AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"];
[FIRApp configure];
self.moduleName = @"AwesomeProject";
self.initialProps = @{};
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
}
- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
Steps Taken to Resolve
I’ve tried the following to fix the error, but the issue persists:
- Added use_modular_headers! in the Podfile to support static libraries and avoid conflicts with React Native.
- Added Firebase dependencies explicitly in the Podfile with :modular_headers => true.
- Ran pod deintegrate, deleted Podfile.lock and Pods/, then ran
pod install --repo-update. - Cleaned the Xcode build folder (Cmd + Shift + K) and deleted Derived Data (~/Library/Developer/Xcode/DerivedData).
- Ensured GoogleService-Info.plist is added to the Xcode project and included in the target’s "Build Phases > Copy Bundle Resources".
- Set Enable Bitcode to NO in Xcode Build Settings.
- Added a dummy Swift file and bridging header to enable Swift support:
- Created Dummy.swift in the project.
- Set Objective-C Bridging Header to AwesomeProject-Bridging-Header.h in Build Settings.
- Added #import <FirebaseAuth/FirebaseAuth-Swift.h> to AwesomeProject-Bridging-Header.h.
- Verified Header Search Paths includes $(inherited) and is not overridden.
- Ran
npx react-native run-iosand built directly in Xcode.
Error Details
When building in Xcode, I get the following error:
In file included from /path/to/project/ios/AwesomeProject/AppDelegate.mm:3:
/path/to/project/ios/Pods/Headers/Public/Firebase/Firebase.h:40:15: fatal error: 'FirebaseAuth/FirebaseAuth-Swift.h' file not found
#import <FirebaseAuth/FirebaseAuth-Swift.h>
Additional Context
The project uses react-native-maps with Google Maps, which is working fine. I’m initializing Firebase in AppDelegate.mm with [FIRApp configure]. My package.json includes:
"@react-native-firebase/app": "^21.0.0",
"@react-native-firebase/auth": "^21.0.0",
"react-native-maps": "^1.8.0"
I’ve ensured the Firebase iOS SDK requirements are met (Xcode 15.2+, macOS 13.5+).