77

I am building an app by Flutter. I got this error message when doing "pod install" or "pod install --repo-update" or "pod update" and the pod install failed and stopped.

The error message:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod FirebaseCoreInternal-library depends upon GoogleUtilities-library, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.

My Podfile:

platform :ios, '11.0'

...

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

...
2
  • 1
    Same issue when I upgrade my Xcode and Firebase version. Got any idea to solve this issue? I am trying to use another method to import firebase (xcode package manager), not sure if it works or not. Jun 7, 2022 at 8:35
  • You can try the steps below, they helped me Jun 8, 2022 at 14:43

18 Answers 18

157

You may not need to use use_frameworks! or use_modular_headers! because it's getting conflict with use_flipper

You can add the following without using them in ios/Podfile:

  platform :ios, '12.4'
  ...
  ...
  
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  #....add any library need headers

Best

3
87

For newest version of firebase 15.1.1 with react-native 0.69.1 no need to enable use_frameworks because it will lead to errors in deploying in real devices

So you just need to add the firebase modulars and set headers to true.

     pod 'Firebase', :modular_headers => true
     pod 'FirebaseCore', :modular_headers => true
     pod 'GoogleUtilities', :modular_headers => true
     $RNFirebaseAsStaticFramework = true

And keep using flipper

  use_flipper!()

I tested it on both Android and IOS on real devices and it works great! 🎉

Here is what 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'
    
    platform :ios, '12.4'
    install! 'cocoapods', :deterministic_uuids => false
    
    target 'myApp' do
      config = use_native_modules!
      flags = get_default_flags()
        
      pod 'Firebase', :modular_headers => true
      pod 'FirebaseCore', :modular_headers => true
      pod 'GoogleUtilities', :modular_headers => true
      $RNFirebaseAsStaticFramework = true
    
    
      use_react_native!(
        :path => config[:reactNativePath],
        # to enable hermes on iOS, change `false` to `true` and then install pods
        :hermes_enabled => flags[:hermes_enabled],
        :fabric_enabled => flags[:fabric_enabled],
        # An absolute path to your application root.
        :app_path => "#{Pod::Config.instance.installation_root}/.."
      )
    
      target 'myAppTests' do
        inherit! :complete
        # Pods for testing
      end
    
      # Enables Flipper.
      #
      # Note that if you have use_frameworks! enabled, Flipper will not work and
      # you should disable the next line.
      use_flipper!()
    
      post_install do |installer|
        react_native_post_install(installer)
        __apply_Xcode_12_5_M1_post_install_workaround(installer)
      end
    end

-

UPDATED 20/Jul

If you wanted to use rich content notifications like notifications with images. Following this article by firebase will ask you to enable use_frameworks as well so my solution for that is to use modular_headers => true for the following packages

target 'richNotification' do
    pod 'FirebaseCoreInternal', :modular_headers => true
    pod 'Firebase/Messaging', :modular_headers => true
    pod 'GoogleUtilities', :modular_headers => true
end

NOTE: Make sure richNotification target is at the bottom of the podfile. see below how my final 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'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

target 'MyApp' do
  config = use_native_modules!
  flags = get_default_flags()

#     use_frameworks! :linkage => :static
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true
  # Flags change depending on the env values.


  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

target 'richNotification' do
    pod 'FirebaseCoreInternal', :modular_headers => true
    pod 'Firebase/Messaging', :modular_headers => true
    pod 'GoogleUtilities', :modular_headers => true
end

I tested it on both Android and IOS, it works great!! 🎉

For Testing Send the following JSON data to https://fcm.googleapis.com/fcm/send as a"POST", and make sure to put in the headers "mutable-content": "1", See the screenshot below

{
        "to": " Put here your mobile fcm token ",
        "notification": {
            "title": "You have received a new request",
            "body": "Radiohead - Street Spirit (Fade Out)",
            "content_available" : "true",
            "priority" : "high",
            "sound":"defualt",
            "image": "https://i.ytimg.com/vi/LCJblaUkkfc/hq720.jpg"
        },
        "android": {
          "priority": "high",
          "notification": {
            "imageUrl": "https://www.youtube.com/watch?v=o3mP3mJDL2k"
          }
        },
        "apns": {
          "payload": {
            "aps": {
              "mutable-content": "1",
              "content-available": "true",
            },
            "imageUrl": "https://i.ytimg.com/vi/panR4xwt0wM/hqdefault.jpg",
            "fcm_options": {
              "imageUrl": "https://i.ytimg.com/vi/panR4xwt0wM/hqdefault.jpg"
            }
          },
          "headers": {
            "mutable-content": "1",
            "apns-push-type": "background",
            "apns-priority": "5", 
            "apns-topic": "com.paidtabs" 
          }
        },
        "webpush": {
          "headers": {
            "image": "https://koenig-media.raywenderlich.com/uploads/2021/01/good_news_petsicon.png"
          }
        },
        "data":{
          "passingDataToApp" : "Mario",
          "body" : "great match!",
          "Room" : "PortugalVSDenmark"
        }
      }

Headers look like headers

3
  • 4
    you sir are a legend, we need more people like you around here! Jul 30, 2022 at 13:53
  • 3
    YOU ARE A FREAKING LEGEND MY GUY, I KEPT TYPING THE POD 'firebase'... stuff into terminal, my problem would've been fixed 4 days ago if people posted their podfile snippet. THANK YOU
    – Anteos1
    Jul 31, 2022 at 15:04
  • Is the advice to remove use_frameworks! suitable for Flutter (not React-Native)? Is there any documentation that explains what's going on with this?
    – fpsColton
    Oct 11, 2022 at 21:18
15

pod 'GoogleUtilities', :modular_headers => true;

add this line to podfile

2
  • 1
    Thanks! Adding only this line was sufficient
    – dentemm
    Sep 25, 2022 at 18:54
  • 1
    This worked to solve my immediate problem but then did ultimately have to add the same thing for Firebase and FirebaseCore for other reasons. Feb 17 at 2:14
14

Removing use_frameworks because is conflicting with use_flipper and adding all this libs worked for me

  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

Heads up! FirebaseFunctions-h.swift and FirebaseStorage-h.swift requires use_frameworks, so probably you may have an error with these files. Perhaps you may prefer use axios or similar lib to invoke your endpoint api and/or aws s3 to save your file instead.

1
  • Yup - after a day of attempts, the above worked. Honestly upgrading deps for ios is such a chore.
    – Adam
    Jul 24, 2022 at 17:27
9

None of the previously suggested solutions worked for me (I also use Expo), however, adding the following snippet to app.config.js solved it for me:

  1. Run npx expo install expo-build-properties
  2. In app.config.js add: <<<< CRITICAL STEP Referenced here
 plugins: [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          ios: {
            useFrameworks: "static",
          },
        },
      ],
  1. My Podfile
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

platform :ios, podfile_properties['ios.deploymentTarget'] || '12.4'
install! 'cocoapods',
  :deterministic_uuids => false

target 'ProjectName' do
  use_expo_modules!
  config = use_native_modules!

#   use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

  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

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

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Dir.pwd}/.."
  )

  # Uncomment to opt-in to using Flipper
  # Note that if you have use_frameworks! enabled, Flipper will not work
  #
  # if !ENV['CI']
  use_flipper!()
  # end

  post_install do |installer|
    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

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end
  1. Don't forget to cd ios && pod install
  2. Run your build, e.g. eas build --platform ios --profile development --local

RNFirebase versions

    "@react-native-firebase/analytics": "15.4",
    "@react-native-firebase/app": "15.4",
    "@react-native-firebase/auth": "15.4",
    "@react-native-firebase/crashlytics": "15.4",
    "@react-native-firebase/firestore": "15.4",
    "@react-native-firebase/perf": "15.4",
3
  • 1
    This works for expo managed projects! also can be referenced here github.com/invertase/react-native-firebase/issues/… if it is a managed project you do NOT need to deal with all the podfile stuff.
    – Starfs
    Dec 17, 2022 at 17:49
  • 1
    Managed workflow team user here. Doing steps 1 and 2 (removed "@react-native-firebase/app" and added quotes to ios and useFrameworks) resolved our EAS iOS build issue. Thank you
    – Mayhaffs
    Feb 27 at 23:11
  • That's a valid answer, on top of those pods, from version 17.3.2 of @react-native-firebase/*, it'll ask you also for FirebaseInstallations, GoogleDataTransport, and nanopb. Mar 14 at 7:47
9

This worked for me too. @virluz just adding to your answer

Version of firebase 16.5 with react-native 70.5

Just add

pod 'GoogleUtilities', :modular_headers => true;

Between below code :

flags = get_default_flags()

    pod 'GoogleUtilities', :modular_headers => true;


  use_react_native!(
    :path => config[:reactNativePath],

After that you can run

arch -x86_64 pod install
8

Finally after going through so many questions the answer was to user Flipper and modular_header in same time, finally my Pod file 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'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

target 'MyPregnancy' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  
  target 'MyPregnancyTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

8

Regarding Expo managed, here's a config plugin that I've made, and works for me

const fs = require('fs');
const path = require('path');
const generateCode = require('@expo/config-plugins/build/utils/generateCode');
const configPlugins = require('@expo/config-plugins');

const code = `  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true`;

const withReactNativeFirebase = (config) => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        'Podfile'
      );
      const contents = fs.readFileSync(filePath, 'utf-8');

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      });

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withReactNativeFirebase;
3
  • 1
    You are a hero!!! Thanks a lot! Guys, more detailed info you can find here: docs.expo.dev/guides/config-plugins For this answer work: 1. Create a file in the root folder for example "firebase-fix.plugin.js" 2. Specify the plugin in the app.json. In "expo.plugins" add ["./expo-plugins/firebase-fix.plugin", "custom"] to plugins array (yes, add array in the array) Sep 14, 2022 at 13:02
  • 1
    thanks, add ["./expo-plugins/firebase-fix.plugin" ] in the plugin list works
    – gasolin
    Oct 5, 2022 at 4:22
  • I am having trouble understanding how to implement this. Is there a way to show how this looks when added to your app.config.js file? I see the comments here and have read the docs on this but am still confused how to implement and where to put this file, and what associated files/configurations are necessary.
    – Starfs
    Dec 17, 2022 at 16:55
7

❗️ React Native developers:

I asked the maintainers of react-native-firebase about the solutions found here and they said the app will eventually break with these workarounds as modules are converted to Swift. FirebaseFunctions-h.swift and FirebaseStorage-h.swift already won't work. Here's the copy pasted answer:

that's an unsupportable workaround to avoid use_frameworks, it is temporarily working for you at best, does not work already if you use storage or functions modules, and other modules will stop working as they fully convert to Swift. I strongly discourage anyone from using that.

The correct solution is to incorporate use_frameworks and drop dependencies that don't support it or work in those repos that you cannot drop such that it is supported

Original answer: https://github.com/invertase/react-native-firebase/issues/6594#issuecomment-1303612795

EDIT: Here's also an official discussion from the React Native community: https://github.com/react-native-community/discussions-and-proposals/discussions/546#discussioncomment-4168642

3

Add to Podfile and update pod

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers =>
true
  $RNFirebaseAsStaticFramework = true
1

For native app projects, here's the Firebase Apple SDK Release Notes (Version 9.0.0):

CocoaPods Users

Breaking change: Podfiles must include use_frameworks! or use_frameworks! :linkage => :static.

Just add either line in your Podfile. The difference is explained in the document: Link Firebase dependencies statically or dynamically.

0

Just a heads up for those desperately trying to fix this, using the newest packages, you may end up dealing with the warning "concurrency is only supported in IOS 15". That looks to be a dead end. It may be in your best interest to downgrade the package and wait for react native +70.0.

0

For me the issue was simply because the version of the Podfile was not compatible with the new version of Firebase modules.

I am working on React Native, so the version of Podfile generated was not the latest one. Due to this my Firebase modules required something else in the Podfile.

It was an easy fix to add in the Podfile:

use_modular_headers!

However, you can also keep an eye on the history of your packages. I had React Native 0.69 that was released in June. I just checked the Firebase packaged version at that time and I have installed those ones. This works as well.

0

I followed kvba 's config plugin. I'm forcing the FirebaseSDKVersion to 10.1.0:

const fs = require('fs')
const path = require('path')
const generateCode = require('@expo/config-plugins/build/utils/generateCode')
const configPlugins = require('@expo/config-plugins')

const code = `  $RNFirebaseAsStaticFramework = true

  # Override Firebase SDK Version
  $FirebaseSDKVersion = '10.1.0'`

const withReactNativeFirebase = config => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async config => {
      const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile')
      const contents = fs.readFileSync(filePath, 'utf-8')

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      })

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed.",
        )
        return config
      }

      fs.writeFileSync(filePath, addCode.contents)

      return config
    },
  ])
}

module.exports = withReactNativeFirebase

0

Add this in the Pod file before the target

use_frameworks! :linkage => :static

This is work well for React Native Application

0
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

target 'SeRemo' do
  config = use_native_modules!
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true
  # 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.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'SeRemoTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enable`enter code here`d => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end
0

I added only these 2 lines

  use_frameworks!
  use_modular_headers!

Podfile (IOS)

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
-1

This fixed it for me on expo EAS:

Add expo-build-properties package

npx expo install expo-build-properties

Update app.json to include:

  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}
1
  • Please do not post duplicate answers.
    – HangarRash
    Mar 21 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.