react native – How to resolve “You attempted to use a firebase module that’s not installed natively on your iOS project” so I can use the firestore emulator?


I’m using firestore successfully in my app. I can call my database and add/query data.

I see that there is a Cloud Firestore Emulator which says it’s good for integration tests.

But if I call a jest test, I get this error:

You attempted to use a firebase module that's not installed natively on your iOS project by calling

    Ensure you have either linked the module or added it to your projects Podfile.

    See for full setup instructions.

       6 |
       7 | if (__DEV__) {
    >  8 |     firestore().useEmulator('localhost', 8080);
         |              ^
       9 | }

The module is installed natively on iOS. I’ve tried a bunch of different fixes I found online, such as manually including the pod in the podfile tests target or adding my pods to Header Search Paths in the XCode build settings. Nothing makes a difference.

The only suggestion I’ve found that I haven’t tried is to mock firestore, since that seems like it would bypass the firestore emulator.

How can I fix this error and move on?

This is my Podfile:

# from
$RNFirebaseAsStaticFramework = true

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 'CupbearerApp' do
  # Per (the linkage static part is for compatibility with Hermes)
  use_frameworks! :linkage => :static
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

    :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],
    # Per flipper is incompatible with use_frameworks
    #:flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."

  target 'CupbearerAppTests' do
    inherit! :complete
    # Pods for testing

  post_install do |installer|