Skip to content

[🐛] 🔥 [runtime not ready]: Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() [RN -0.78] [iOS only] #8461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 7 tasks
DonovanEnas opened this issue Apr 9, 2025 · 13 comments

Comments

@DonovanEnas
Copy link

Issue

Got this issue while upgrading react native version to 0.78, i have tried cleaning the project, node_modules, yarn cache and Pods and podfile.lock. Also my AppDelegate.swift has import FirebaseCore and FirebaseApp.configure() which i saw were solutions to a similar issue that was reporeted. Could get the app running fine on android.


Project Files

Javascript

Click To Expand

package.json:

{
  "name": "appname",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "lint:fix": "yarn lint -- --fix",
    "format": "prettier --check .",
    "format:fix": "prettier --write .",
    "buildApk": "cd android && ./gradlew clean && ./gradlew assembleRelease && cd ..",
    "postinstall": "patch-package",
    "cleanProject": "watchman watch-del-all && rm -rf yarn.lock package-lock.json node_modules ios/Pods ios/Podfile.lock android/app/build && npm install && cd ios && pod update && cd .. && npm start -- --reset-cache"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "./src/*.js": [
      "yarn format && yarn format:fix && yarn lint"
    ]
  },
  "dependencies": {
    "@gorhom/bottom-sheet": "^5.1.2",
    "@notifee/react-native": "^9.1.8",
    "@react-native-async-storage/async-storage": "^2.0.0",
    "@react-native-camera-roll/camera-roll": "^7.3.0",
    "@react-native-clipboard/clipboard": "^1.16.0",
    "@react-native-community/cli": "15.0.1",
    "@react-native-community/cli-platform-android": "15.0.1",
    "@react-native-community/cli-platform-ios": "15.0.1",
    "@react-native-community/datetimepicker": "^8.0.0",
    "@react-native-community/geolocation": "^3.4.0",
    "@react-native-community/netinfo": "^11.3.3",
    "@react-native-firebase/app": "^21.13.0",
    "@react-native-firebase/crashlytics": "^21.13.0",
    "@react-native-firebase/messaging": "^21.13.0",
    "@react-native-picker/picker": "^2.4.1",
    "@react-native/babel-preset": "^0.78.0",
    "@react-navigation/bottom-tabs": "^7.3.3",
    "@react-navigation/drawer": "^7.3.2",
    "@react-navigation/elements": "^2.3.1",
    "@react-navigation/material-top-tabs": "^7.2.3",
    "@react-navigation/native": "^7.0.19",
    "@react-navigation/stack": "^6.3.21",
    "@rematch/core": "^2.2.0",
    "@rematch/loading": "^2.1.2",
    "@rematch/persist": "^2.1.2",
    "accordion-collapse-react-native": "^1.1.1",
    "axios": "^1.8.4",
    "axios-retry": "^4.5.0",
    "babel-eslint": "^10.1.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint-plugin-prettier": "^5.2.5",
    "eslint-plugin-react-native": "^4.0.0",
    "jwt-decode": "3.1.2",
    "lodash.debounce": "^4.0.8",
    "lodash.groupby": "^4.6.0",
    "moment": "^2.29.3",
    "patch-package": "^8.0.0",
    "payu-non-seam-less-react": "^3.3.0",
    "query-string": "^8.1.0",
    "react": "19.0.0",
    "react-content-loader": "^6.2.1",
    "react-hook-form": "^7.49.3",
    "react-native": "^0.78.0",
    "react-native-app-auth": "^6.4.3",
    "react-native-calendars": "^1.1284.0",
    "react-native-camera": "^4.2.1",
    "react-native-country-flag": "^2.0.2",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-device-info": "^10.12.0",
    "react-native-drop-shadow": "^1.0.0",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^2.24.0",
    "react-native-get-random-values": "^1.8.0",
    "react-native-iap": "^12.10.5",
    "react-native-image-crop-picker": "^0.42.0",
    "react-native-image-picker": "^8.2.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-localize": "^3.4.1",
    "react-native-maps": "^1.20.1",
    "react-native-modal": "^14.0.0-rc.1",
    "react-native-modal-datetime-picker": "^18.0.0",
    "react-native-otp-entry": "^1.8.2",
    "react-native-pager-view": "^6.7.0",
    "react-native-paper": "5.1.3",
    "react-native-permissions": "3.3.1",
    "react-native-phone-input": "^1.3.3",
    "react-native-popup-menu": "^0.16.1",
    "react-native-qrcode-svg": "^6.1.2",
    "react-native-reanimated": "^3.17.2",
    "react-native-reanimated-carousel": "^3.1.5",
    "react-native-safe-area-context": "^5.3.0",
    "react-native-screens": "^4.9.2",
    "react-native-share": "^12.0.9",
    "react-native-simple-toast": "^3.2.0",
    "react-native-slider": "^0.11.0",
    "react-native-sound-player": "^0.14.5",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^15.11.2",
    "react-native-switch-selector": "^2.3.0",
    "react-native-tab-view": "^3.1.1",
    "react-native-toast-message": "^2.1.5",
    "react-native-url-polyfill": "^2.0.0",
    "react-native-version-info": "^1.1.1",
    "react-native-webview": "^13.13.1",
    "react-redux": "8.0.2",
    "redux": "^4.2.0",
    "update": "^0.7.4",
    "uuid": "^9.0.0",
    "victory-native": "^36.6.8"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.23.8",
    "@babel/runtime": "^7.23.8",
    "@react-native/babel-preset": "^0.78.0",
    "@react-native/eslint-config": "^0.73.2",
    "@react-native/metro-config": "^0.78.0",
    "@react-native/typescript-config": "0.74.0",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "lint-staged": "^15.2.0",
    "metro": "^0.82.1",
    "metro-config": "^0.82.1",
    "prettier": "3.2.2",
    "react-native-svg-transformer": "^1.0.0",
    "react-test-renderer": "19.0.0",
    "redux-persist": "^6.0.0",
    "typescript": "5.1.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

# 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!


linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym # For Firebase
end

target 'AppName' do
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'RNIap', :path => '../node_modules/react-native-iap'
  pod 'TrustKit'
  config = use_native_modules!
  use_frameworks! :linkage => :static 
  $RNFirebaseAsStaticFramework = true
  flags = get_default_flags()
  
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'
  pod 'react-native-google-maps', :path => '../node_modules/react-native-maps' # This script is for the google maps if not needed then please skip this one
  # <--- FCM(Firebase push notification) setup scripts End 
  
  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  

  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
    )
  end
end

AppDelegate.swift:

import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import RNBootSplash 
import FirebaseCore // ⬅️ this
import FirebaseMessaging

@main
class AppDelegate: RCTAppDelegate {
  override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
    self.moduleName = "AppName"
    self.dependencyProvider = RCTAppDependencyProvider()

    // 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 = [:]
    FirebaseApp.configure() // ⬅️ this
    Messaging.messaging().delegate = self
    application.registerForRemoteNotifications()

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  override func sourceURL(for bridge: RCTBridge) -> URL? {
    self.bundleURL()
  }

  override func bundleURL() -> URL? {
#if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
  }

  // ⬇️ override this method
  override func customize(_ rootView: RCTRootView!) {
    super.customize(rootView)
    RNBootSplash.initWithStoryboard("BootSplash", rootView: rootView) // ⬅️ initialize the splash screen
  }
  override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  Messaging.messaging().apnsToken = deviceToken
  }
  // Add the following function if needed (for firebase)
// MARK: - MessagingDelegate
  extension AppDelegate: MessagingDelegate {
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        // // Send token to your server if needed
        if let token = fcmToken {
            let dataDict: [String: String] = ["token": token]
            NotificationCenter.default.post(
                name: Notification.Name("FCMToken"),
                object: nil,
                userInfo: dataDict
            )
        }
    }
  }
}

Environment

Click To Expand

react-native info output:

 System:
  OS: macOS 15.3.2
  CPU: (10) x64 Apple M4
  Memory: 36.07 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 23.10.0
    path: ~/.nvm/versions/node/v23.10.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v23.10.0/bin/npm
  Watchman:
    version: 2025.03.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.4
      - iOS 18.4
      - macOS 15.4
      - tvOS 18.4
      - visionOS 2.4
      - watchOS 11.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.12816248
  Xcode:
    version: 16.3/16E140
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 3.2.0
    path: /.rvm/rubies/ruby-3.2.0/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.2
    wanted: ^0.78.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 21.13.0
  • Firebase module(s) you're using that has the issue:
    • e.g. crashlytics, messaging
  • Are you using TypeScript?
    • N

@mikehardy
Copy link
Collaborator

This has been brought up a few times, but I've never reproduced it locally.
I have an automated build script that works every time - something it is doing is missing in your project
https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

Last time someone brought this up, they hadn't properly added their GoogleServices-Info.plist to their project, could be that?
Check the script though, it definitely works. There is no problem with react-native-firebase current and react-native 0.78 and iOS in general, just project-specific problems for some folks

@DonovanEnas
Copy link
Author

I could get the app Initialized from the script running, but it still doesnt fix my issue @mikehardy

@mikehardy
Copy link
Collaborator

We're not able to fix every project-specific problem for every project, that's an unrealistic expectation given it's an infinite demand for support on a limited support resource.

We can prove it can work, and we can show you how in a reproducible way - which we have done - and by comparison with your project you can find the integration error in your project

@DonovanEnas
Copy link
Author

@mikehardy I dont intend so. But i have run the script compared it with my project files (focused more on comparing Pods, Gemfile and AppDelegate, but could not find any major deviations. Are there any more file or areas that u suggest i might need to check?

@mikehardy
Copy link
Collaborator

Read the entire script, it's well commented, and verify every single item

@haddad-yacine
Copy link

If you are using Expo 53 or React Native 0.79, you might encounter this issue with React Native Firebase. The problem is that the Firebase plugin is looking for a specific pattern in the AppDelegate.swift file:

self.moduleName = "main"

However, in Expo 53, this pattern has been replaced with:

reactNativeFactory?.startReactNative(
  withModuleName: "main",
  in: window,
  launchOptions: launchOptions)

The Firebase plugin uses a regex pattern to find where to insert FirebaseApp.configure(), but it can't find the expected pattern in the new AppDelegate structure.

Solution:
After running expo prebuild, you need to manually add FirebaseApp.configure() to your AppDelegate.swift file. Add it right before the reactNativeFactory?.startReactNative call:

// Configure Firebase
FirebaseApp.configure()

reactNativeFactory?.startReactNative(
  withModuleName: "main",
  in: window,
  launchOptions: launchOptions)

This is a temporary workaround until the Firebase plugin is updated to support the new AppDelegate structure in Expo 53. The issue is in the plugin's regex pattern that's looking for the old structure.

@iM-GeeKy
Copy link

@haddad-yacine Do you have a patch for this and are you seeing it on Android as well with Expo 53 and React Native 0.79?

@haddad-yacine
Copy link

haddad-yacine commented Apr 26, 2025

@iM-GeeKy

No, I only see that in iOS, as I said, I just add the FirebaseApp.configure() right before the reactNativeFactory?.startReactNative call in the AppDelegate.swift file, after doing the npx expo prebuild --clean.

@iM-GeeKy
Copy link

iM-GeeKy commented Apr 26, 2025

@haddad-yacine Okay I'm having some issues on Android with this as well after upgrading to Expo 53 and React Native 0.79. I have been talking with one of the Expo developers and he said sdk 53 introduces the AppDelegate in swift as well as using the RCTReactNativeFactory in all apps. This is a breaking change and third party config plugins will need changes, so that makes sense why iOS may have related issues and tracks with your workaround. It actually looks like there is a merge request for it.

@haddad-yacine
Copy link

@iM-GeeKy I just rechecked the android build, and it's working fine, so it's working in both iOS and Android, just make sure to clean the project before prebuilding, remove node modules and yarn lock file.

@iM-GeeKy
Copy link

iM-GeeKy commented Apr 26, 2025

@haddad-yacine I'm not using expo-prebuild with my dev client, but I appreciate the heads up 👍🏻

@hirbod
Copy link
Contributor

hirbod commented Apr 28, 2025

The PR #8490 adds auth support, but SDK 53 initialization is still failing for the core package @react-native-firebase/app because, as @haddad-yacine correctly pointed out, the AppDelegate.swift has changed and this regexp is failing, thus not adding FirebaseApp.configure().

You can also see

» ios: @react-native-firebase/app: Unable to determine correct Firebase insertion point in AppDelegate.swift. Skipping Firebase addition.

during the prebuild phase.

The patch is pretty easily done by changing the regular expression to

/(?:self\.moduleName\s*=\s*"([^"]*)")|(?:reactNativeFactory\?\.\s*startReactNative)/

I'm preparing a PR now.

@hirbod
Copy link
Contributor

hirbod commented Apr 28, 2025

The PR draft is here:
#8495

A temp patch is here:

diff --git a/plugin/build/ios/appDelegate.js b/plugin/build/ios/appDelegate.js
index c1e95803368b6b6bb1ddf9cdcbdade2a8a91a664..90c8660a486061f8b1835fc7a88a8bb6d66ef735 100644
--- a/plugin/build/ios/appDelegate.js
+++ b/plugin/build/ios/appDelegate.js
@@ -61,7 +61,7 @@ function modifyObjcAppDelegate(contents) {
 }
 function modifySwiftAppDelegate(contents) {
     const methodInvocationBlock = `FirebaseApp.configure()`;
-    const methodInvocationLineMatcher = /(?:self\.moduleName\s*=\s*"([^"]*)")/g;
+    const methodInvocationLineMatcher = /(?:self\.moduleName\s*=\s*"([^"]*)")|(?:reactNativeFactory\?\.\s*startReactNative)/;
     // Add import
     if (!contents.includes('import FirebaseCore')) {
         contents = contents.replace(/import Expo/g, `import Expo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@hirbod @mikehardy @iM-GeeKy @haddad-yacine @MichaelVerdon @DonovanEnas and others