0

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-ios and 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+).

1 Answer 1

0

I Solved It By Updating My pod File and appDcelgate.mm Like This

# Resolve react_native_pods.rb with node to allow for hoisting
    require Pod::Executable.execute_command('node', ['-p',
      'require.resolve(
        "react-native/scripts/react_native_pods.rb",
        {paths: [process.argv[1]]},
      )', __dir__]).strip
    
    platform :ios, min_ios_version_supported
    prepare_react_native_project!
    
    
    # Define the path to react-native-maps
    rn_maps_path = '../node_modules/react-native-maps'
    
    linkage = ENV['USE_FRAMEWORKS']
    if linkage != nil
      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_frameworks! 
      use_frameworks! :linkage => :static
      $RNFirebaseAsStaticFramework = true
    
      use_react_native!(
        :path => config[:reactNativePath],
        :hermes_enabled => false,
        :app_path => "#{Pod::Config.instance.installation_root}/.."
      )
      
      # Add Google Maps for iOS
      pod 'GoogleMaps'
      pod 'Google-Maps-iOS-Utils'
      pod 'react-native-google-maps', :path => rn_maps_path
       
    
      pod 'Firebase/Auth', :modular_headers => true
      pod 'Firebase/Core', :modular_headers => true
      pod 'GoogleUtilities', :modular_headers => true
    
      target 'AwesomeProjectTests' do
        inherit! :complete
        # Pods for testing
      end
    
      post_install do |installer|
        # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
        react_native_post_install(
          installer,
          config[:reactNativePath],
          :mac_catalyst_enabled => false,
          # :ccache_enabled => true
        )
        
        # This is necessary for Xcode 14
        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

also in appDelegate.mm

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <GoogleMaps/GoogleMaps.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  [FIRApp configure];
  // Add this line to initialize Google Maps with your API key
  [GMSServices provideAPIKey:@"AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"];
  
  self.moduleName = @"AwesomeProject";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.