One long-standing issue with Cloud Firestore is that Flutter Xcode builds take a long time, especially on CI environments. This is because the Firestore iOS depends on 500k lines of mostly C++ code, that are compiled from scratch as part of the Xcode build.
Fortunately, a solution is now available and documented here:
To speed up your build times, you can use invertase/firestore-ios-sdk-frameworks, which contains precompiled Firestore iOS SDKs extracted from the Firebase iOS SDK release downloads.
sponsor

Level up your Flutter app’s performance. Get full visibility into your Flutter app’s performance, including crashes, exceptions in Dart, network health, custom traces, and more. Solve your trickiest issues, optimize user journeys, and wow your end users - again and again.
To take advantage of this, follow these two steps:
1. Find which version of the Firestore iOS SDK is in use
You can do so by opening the ios/Podfile.lock
and searching for cloud_firestore
.
You should find something like this:
- cloud_firestore (3.1.4):
- Firebase/Firestore (= 8.9.0)
- firebase_core
- Flutter
Make a note of the Firebase/Firestore
version (8.9.0
in this case).
2. Use the precompiled Firestore iOS SDK
Open the Podfile
inside the ios
folder, then add this line inside your target 'Runner' do
block:
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.9.0'
# ...
end
Note: the first time you try this, you may get this error log:
[!] CocoaPods could not find compatible versions for pod "FirebaseFirestore":
In snapshot (Podfile.lock):
FirebaseFirestore (= 8.9.1, ~> 8.9.0)
In Podfile:
FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `8.9.0`)
None of your spec sources contain a spec satisfying the dependencies: `FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `8.9.0`), FirebaseFirestore (= 8.9.1, ~> 8.9.0)`.
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
This is solved by removing ios/Podfile.lock
and rebuilding.
You're welcome! 😎