Flutter on IOS: fatal error: module 'cloud_firestore' not found
If you are using Android Studio the error might occur if you are creating the Podfile manually.
Flutter runs using just the pubspec.yaml file. You don't have to set up the Podfile by yourself. If you follow the installation guideline on the firestore homepage just skip everything after adding GoogleService-Info.plist file using Xcode.
Flutter (iOS) - Module 'cloud_firestore' not found in GeneratedPluginRegistrant.m
Finally after days of trying and error, I found a way to work it out..
So, I noticed several things that might cause an error when building for iOS.
Never run the command
pod install
manually.Do not add the line
pod install Firebase
to your podfile. Instead, just override all of the firebase dependencies using$FirebaseSDKVersion = '8.0.0'
Don't forget to specify your iOS Deployment target on your podfile and match it with the deployment target on your Runner.xcworkspace file (Both in the runner and in the target)
So, if you already have a project, here are the steps I recommend, as this works perfectly for me:
Delete the Pods directory, the /ios/podfile.lock, and the ios/Flutter/Flutter.podspec
Run
pod deintegrate
Delete all of the contents inside your DerivedData folder.. you can run
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Run
flutter clean
Run
flutter pub get
Run
flutter build ios
. Note thas this will also run thepod install
command.Close your editor, and open your Runner.xcworkspace on XCode and run your XCode. Clean your build folder. If there's an option to update your project settings, accept it.
You might get several warnings about deprecated functions, but in my case, my app run just fine..
I don't know about the details on why it happened, but from what I noticed, Cocoapods have a different version of some of the firebase packages for ios.. I hope someone can explain it..
--
Things to note :
If build your app on XCode, and then use
flutter run
either on terminal or VSCode, you would get some warnings like Class AMSupportURLConnectionDelegate is implemented in both. So, from my personal experience, I always run my app from XCode.If you use Google Sign In, follow the steps here you don't need to add anything in your podfile.
For reference, here is my podfile content.
# Uncomment the next line to define a global platform for your project
# platform :ios, '12.0'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
$FirebaseSDKVersion = '8.0.0'
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)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
I hope it works for you! Goodluck!
module 'cloud_firestore' not found (Flutter)
Update the firestore version:
cloud_firestore: ^0.13.6
Related Topics
Present a Modal View Controller with Transparent Background
Uisearchdisplaycontroller Without Dimming
iOS - Is Motion Activity Enabled in Settings > Privacy > Motion Activity
Ipa Generated by Swift Is So Big, About 5Mb
iOS Swift: Could Not Cast Value Type '_Nscfnumber' to 'Nsstring'
Make Timer Run on Background iOS for More Than 3 Minutes
Add Modal Popup to Map Annotation - Swift 3.0
iPhone Uibutton - Image Position
Watchkit Extension Bundle Identifiers
iPhone Storage in Tmp Directory
How to Convert from Uiimage to Heif/Heic Data in Swift
Swift iOS9 New Contacts Framework - How to Retrieve Only Cncontact That Has a Valid Email Address
How Reliable Is Kvo with Uikit
How to Edit Uialertaction Title Font Size and Style
Swift Compatibility Between Versions for a Library
Storyboard Is Not Showing Custom Color Hex Code in Xcode 12.0.1
Removing Duplicate Objects from Fetch Based on Object Parameter Updated Swift