Reputation: 271
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
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:
pod 'FirebaseCore', :modular_headers => true
cd ios && pod install --repo-update
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
Reputation: 1569
In my case, I was using flavors and forgot to select the right scheme.
Upvotes: 0
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
Reputation: 182
The iOS version in deployment info has to match with the version declared in the Podfile.
platform :ios, '12.4'
Upvotes: 3
Reputation: 810
pod 'FirebaseCore', :modular_headers => true
after target 'yourprojectname' do
pod install
in ios dirUpvotes: 11
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
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
Reputation: 141
You need to download and update the packages in the Podfile.
Upvotes: 2
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
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
Reputation: 2148
run pod install in the ios folder of your flutter app
Upvotes: 2