Slow builds, whether locally or in the CI, reduce developer productivity. If you integrated Firestore into your Flutter app, you might have experienced slow build times in your apps.

There have been issues that outline the slow build times developers experience when Firestore is added as a dependency:

These issues affect the speed of getting out builds to testers and users, and it’s also expensive to pay for macOS CI machines on the cloud.

Use pre-compiled Firestore iOS SDK

The issue is caused by the 500k+ lines of mostly C++, which gets compiled as part of the Xcode build process and takes a long time.

The precompiled Firestore iOS SDK solves this problem. It includes xcframework files extracted from the Firebase iOS SDK repository are released and tagged using the Firebase iOS SDK versions.

GitHub - invertase/firestore-ios-sdk-frameworks: ⚡ Precompiled Firestore iOS SDKs extracted from the Firebase iOS SDK repository release downloads for faster build times.

⚡ Precompiled Firestore iOS SDKs extracted from the Firebase iOS SDK repository release downloads for faster build times. - GitHub - invertase/firestore-ios-sdk-frameworks: ⚡ Precompiled Firestore…

Find your Firebase iOS SDK version

Locate the ios/Podfile.lock file.

In the cloud_firestore dependency, check for the Firebase SDK version in the  Firebase/Firestore  line:

PODS:
  - cloud_firestore (3.2.1):
    - Firebase/Firestore (= 9.2.0) 
    - firebase_core
    - Flutter

ios/Podfile.lock

9.2.0 is the Firebase SDK version of this project.

See supported versions for the precompiled Firestore iOS SDK.

Update your Podfile

In your ios/Podfile, reference the precompiled Firestore iOS SDK git repository inside your Runner target:

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  # Add this line
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.2.0'
end

ios/Podfile

Remove ios/Podfile.lock.

Last, run flutter packages get.

That’s it!

It’s a wrap

My tests showed that using the precompiled iOS SDK for Firestore reduced 67% of iOS my project’s build time in the CI.

Build #Old build timeNew build time
11402s491s
21406s453s
31397s464s
41443s479s
51419s463s

See the runs at flutter_firebase_precompiled_sdk

GitHub - joshuadeguzman/flutter_firebase_precompiled_sdk

Contribute to joshuadeguzman/flutter_firebase_precompiled_sdk development by creating an account on GitHub.

Give it a try, and let me know what your build times are at hi@joshuamdeguzman.com 👋