'Error running pod install' After Add cloud_firestore to Flutter
Tags: flutter, firebase, androidstudio
Published: 2020-12-02 12:26:21

## Environment
macOS: 10.15.7
Xcode: 12.2, Build version 12B45b
Android Studio: 4.1.1

I made an app in Android Studio, it compiles fine. But a lot trouble happened after I add `cloud_firestore`.

### The issue
I added
```
firebase_core: ^0.5.2+1
firebase_auth: ^0.18.3+1
cloud_firestore: ^0.14.3+1
```
to `pubspec.yaml`, run app, it says `Error running pod install`.

## 1st try
I thought it's maybe the versions issue, so I downgrade each one to 
```
firebase_core: ^0.3.4
firebase_auth: ^0.8.4+4
cloud_firestore: ^0.9.13+1
```
Same issue.

## 2nd try
Then I folloed [Paresh Mangukiya's answer](https://stackoverflow.com/a/64474526) to try something further
```bash
### Open terminal, go to the project's folder
cd /ios
rm Podfile.lock
pod install --repo-update
flutter clean
```

## 3rd try

Then I add the three dependencies one by one.

First added `firebase_core: ^0.5.2+1`, run app in simulator, OK.
Second added `firebase_auth: ^0.18.3+1`, run app, it says
```
Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
  pod repo update
```
Run `pod repo update`, then run app again, OK.


## 4th try
Next added `cloud_firestore: ^0.9.13+1`, run app, it says `Error running pod install` again, without any more info.

## 5th try
Then I believe it's the problem of `cocoapods` itself. I followed [neilco's answer](https://superuser.com/a/686319) to fully uninstall cocoapods
```bash
gem list --local | grep cocoapods
sudo gem uninstall EACH_OF_THEM
rm -rf ~/.cocoapods
```

## 6th try
Then, I installed `homebrew` and reinstalled `cocoapods`
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install cocoapods
```

## 7th try
After that, redo the steps
```bash
### Open terminal, go to the project's folder
cd /ios
rm Podfile.lock
pod install --repo-update
```
It stuck at `Installing BoringSSL-GRPC (0.0.7)`. I waited about 1 hour, it still stuck there.

## 8th try
After read [Nitish Kumar Singh's post](https://www.nstack.in/blog/grpc-ios-stuck/), I know 
>It downloads more than 1 GB of data when you Firebase(Firestore) to the Flutter Project. This is the reason why it took so long to finish.

After about 3 hours, downloaded a bunch of dependencies
```bash
Installing BoringSSL-GRPC (0.0.7)
Installing Firebase (6.33.0)
Installing FirebaseAuth (6.9.2)
Installing FirebaseCore (6.10.3)
Installing FirebaseCoreDiagnostics (1.7.0)
Installing FirebaseFirestore (1.18.0)
Installing Flutter (1.0.0)
Installing GTMSessionFetcher (1.5.0)
Installing GoogleDataTransport (7.5.1)
Installing GoogleUtilities (6.7.2)
Installing PromisesObjC (1.2.11)
Installing abseil (0.20200225.0)
Installing cloud_firestore (0.14.3-1)
Installing firebase_auth (0.18.3-1)
Installing firebase_core (0.5.2-1)
Installing gRPC-C++ (1.28.2)
Installing gRPC-Core (1.28.2)
Installing leveldb-library (1.22)
Installing nanopb (1.30906.0)
```
After a crazy `232.2s` build time, run successfully.

## Conclusion
Actually I am still not sure what caused the issue after all. But reinstall cocoapods helps in my case.

Hope this helps!
So proud to be a coder!