How to Fix cloud_firestore Errors in Flutter

 ・ 2 min

bonfire near seashore during nighttime

When trying to use Firebase's Firestore in Flutter, adding the package goes fine, but you might run into errors during the build step for the virtual mobile device.

I want to document how I solved this problem.

To install Firestore, it's best to follow the official documentation. Follow the instructions at Set up your development environment.
If you haven't set up Firebase yet, please complete Configure and initialize Firebase first.

When I ran the Flutter project in development mode, the exact error output is gone, but something similar to this appeared in the console:

CocoaPods could not find compatible versions for pod "cloud_firestore":

If you followed the Firestore setup instructions, you should have modified the Podfile.
When I ran gem install cocoapods on my Mac, I got a permission denied-type message.

image

This may not be the direct fix for the Firestore issue, but I referenced a StackOverflow post and installed it with brew install cocoapods. Since I'm on M1, I also added an alias to my default shell zsh.

I opened vim ~/.zshrc in the terminal, added the alias from the StackOverflow link at the end to replace the pod command with an alternative command, applied it with source ~/.zshrc, and restarted VS Code.

After navigating to the ios folder in the Flutter project and running pod install, it seemed like it would work, but the following error appeared:

image

The fix for this is to go to the Podfile, look at the 2nd line where you'll see # platform :ios, '12.0' commented out. Uncomment it and try pod install again, but it'll still error out. The reason is that packages like cloud_firestore, firebase_auth, and firebase_core may have raised their minimum version requirements depending on the version, so you need to bump the version up.

In my case, changing it to 13.0 made pod install complete successfully and the build worked fine too.

image


Peace is not something you wish for. It's something you make, something you do, something you are, and something you give away.

— Robert Fulghum


Other posts
Thoughts on How to Develop 커버 이미지
 ・ 9 min

Thoughts on How to Develop

Hongong Computer Architecture & OS - Week 6 Study Group Homework 커버 이미지
 ・ 4 min

Hongong Computer Architecture & OS - Week 6 Study Group Homework

The U.S. Constitution 커버 이미지
 ・ 18 min

The U.S. Constitution