18

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.

user12784286
  • 181
  • 1
  • 1
  • 3

10 Answers10

27

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.

Naj
  • 723
  • 7
  • 17
  • Occam's Razor Thanks – embarker Feb 02 '22 at 01:07
  • 1
    This is actually very interesting, The Nobel Price Committee should give a special Nuts award to Apple for giving ambiguous names, icons, and folder structures in different places in the same project and making the developers go nuts. – Anees Hameed Apr 14 '23 at 10:34
22

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.

pape saliou ka
  • 402
  • 4
  • 7
  • I though I had that already based on another stack overflow question, but I had `FireBaseCoreInternal`. Not the same thing, make sure to double check – DaReal Dec 01 '22 at 16:39
7
  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...
2

run pod install in the ios folder of your flutter app

  1. open terminal
  2. cd "your-project"/ios
  3. pod install
Florian K
  • 2,033
  • 1
  • 9
  • 21
2

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
khoi
  • 940
  • 1
  • 14
  • 29
1

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

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

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

platform :ios, '12.4'

enter image description here

0

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

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Francisco Maria Calisto Oct 12 '21 at 14:25
0

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.

embarker
  • 194
  • 1
  • 6
0

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

Hasan El-Hefnawy
  • 1,249
  • 1
  • 14
  • 20