I’m a newborn in flutter environment.
I was trying to setup a Cloud Firestore connection to my app. I did most of the coding process on VSCode, but after implementing firestore, I tried building in Xcode since I got some error on VSCode.
Upon building my app in Xcode 12.5.1 (which I opened using Rosetta), I got this error
Error when building app – Module ‘cloud_firestore’ not found
I’ve make sure to add the dependencies either in Podfile or in my Pubspec.yaml file.
Here is My podfile and here is my pubspec.yaml dependencies pubspec.yaml dependencies
I’ve tried several things such as:
-
Deintegrate pod and installing pod again(including deleting the podfile.lock and pods directory and reinstalling the pod again)
-
I’ve tried
flutter clean
->flutter pub get
->flutter build ios
, but still resulting in the same error. -
I have imported my GoogleService-Info.plist to my Runner via Xcode and double checking the name.
What intrigue me is, I also add Firebase_auth package and it works just fine. See the error only showing at the import Cloud Firestore line
Does anyone know how to resolve this error? Any help would be very much appreciated. Thank you so much 🙏
3
Answers
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.
I hope it works for you! Goodluck!
Can you see that the
cloud_firestore
module has been successfully imported under your iOS project?Non of the previous solutions worked for me. After two days of searching I downgraded cocoapods to an older version that I knew had worked in the past:
Uninstalled with
gem uninstall cocoapods
and installed the old version.After that I applied @reneconrad’s answer.