user12784286
user12784286

Reputation: 271

fatal error: module 'firebase_core' not found

Just created a new flutter project, added google-services-info.plist file to iOS and added firebase_core to pubspec.yaml. Ran the project and got this error. Error: fatal error: module 'firebase_core' not found @import firebase_core;

I have searched a lot on the stack overflow and gitlab. Tried all the workarounds like flutter clean, update repo, delete pod and reinstall pod but still got no success in resolving this error.

This has blocked me for 5 days. Unable to find anything on this. Please help.

Link to my project on GitHub. : https://github.com/infonotics/stocklyticsSO Do add your own googleService-Info.plist file to the Runner folder. I have removed my file for security reasons.

Thanks in advance.

Upvotes: 27

Views: 33794

Answers (11)

Mustafa Kahraman
Mustafa Kahraman

Reputation: 51

Same error happened when using Firebase authentication.

Before that, while setting up Firebase for iOS initially (i.e. pod installing for @@react-native-firebase/app) I have gotten the following error: 'The Swift pod 'FirebaseCoreInternal' depends upon 'GoogleUtilities', which does not define modules'. I have solved it by adding pod 'GoogleUtilities', :modular_headers => true; in the Podfile as it is suggested when error displayed.

For the Module 'FirebaseCore' not found error, following method worked for me:

  • Adding this line in Podfiles: pod 'FirebaseCore', :modular_headers => true
  • At the project root directory: cd ios && pod install --repo-update
  • Rebuild project: cd .. && npx react-native run-ios

Related part of my Podfiles at the end:

 target 'MyApp' do
   config = use_native_modules!

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

   pod 'GoogleUtilities', :modular_headers => true
   pod 'FirebaseCore', :modular_headers => true

My setup:

OS: macOS Big Sur 11.7.10
Mac: MacBook Pro 13'' Mid 2014
Xcode: 13.2.1
React Native: 0.72.6
@react-native-firebase/app: 18.6.1
@react-native-firebase/auth: 18.6.1

Upvotes: 0

Hasan El-Hefnawy
Hasan El-Hefnawy

Reputation: 1569

In my case, I was using flavors and forgot to select the right scheme.

Upvotes: 0

pape saliou ka
pape saliou ka

Reputation: 512

I had this issue and here is how I fixed it. cd ios folder and open the Podfile and add this line pod 'FirebaseCore', :modular_headers => true save the file and run pod install

here is a link to the github answer that helped me.

Upvotes: 32

Santiago Curvello
Santiago Curvello

Reputation: 182

The iOS version in deployment info has to match with the version declared in the Podfile.

platform :ios, '12.4'

enter image description here

Upvotes: 3

Chintan Hingrajiya
Chintan Hingrajiya

Reputation: 810

  1. add below line in podfile pod 'FirebaseCore', :modular_headers => true after target 'yourprojectname' do
  2. remove podfile.lock
  3. reinstall pod pod install in ios dir
  4. and above error will gone...

Upvotes: 11

Naj
Naj

Reputation: 853

I assume you have tried opening the ios project in xcode. When opening the project in XCode, make sure you open the file with the .xcworkspace extension instead of the one with .xcodeproj and then build again.

Upvotes: 36

embarker
embarker

Reputation: 194

Its always a tense moment to try everything and if something does not work.

Tried ffi solution, recreating ios folder via flutter create also did not work.

Finally, it worked by closing xcode , flutter clean and then the usual.

One point to note was Identity and Type should be set to Absolute path. I am not sure if that fixed the issue.

Upvotes: 0

You need to download and update the packages in the Podfile.

  1. Open Terminal
  2. cd ./ios
  3. pod update

Upvotes: 2

Kausar Mitha
Kausar Mitha

Reputation: 1

I face this issue for 3 days then i found out the root cause was i was running on M1 so my error got solved after following this link

Upvotes: 0

khoi
khoi

Reputation: 1180

If got any error when open xcode,ignore it and do below step. Type of error: any module firebase not found..(in my case, firebase_core not found) at GeneratedPluginRegistrant.m)

1.0. flutter clean (VS Code)

2.0. flutter pub get (VS Code)

3.0. open ios emulator (VS Code)

4.0. flutter run (VS Code)

5.0 done compile

6.0. close emulator

6.0. open ios folder using xcode (XCODE)

7.0. make sure iphone SE(2nd generation) or any device is selected during compiling (XCODE)

8.1. begin compile (XCODE)

9.2 error gone and done.

Podfile

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

Upvotes: 3

Florian K
Florian K

Reputation: 2148

run pod install in the ios folder of your flutter app

  1. open terminal
  2. cd "your-project"/ios
  3. pod install

Upvotes: 2

Related Questions