✨ New Portfolio Website

Improve Flutter iOS Build Time
 When Using Firestore

Slow builds whether locally or in the CI reduces developer productivity. If you integrated Firestore in your Flutter app, chances are, you may have experienced slow builds in your apps.
- 2 min read
Improve Flutter iOS Build Time
 When Using Firestore

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 time New build time
1 1402s 491s
2 1406s 453s
3 1397s 464s
4 1443s 479s
5 1419s 463s

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 👋




share

Related posts

Build a ChatGPT-Powered Chatbot With Flutter

ChatGPT has stormed the internet in the last four months with its capabilities to understand and generate natural language with remarkable fluency and accuracy. This article outlines how you can take advantage of these powerful AI models and create apps using Flutter and Dart.

Guide To Use GNU Make For Flutter

GNU Make or Make helps simplify commands you need for your Flutter project. Although Make is not a 100% replacement for your shell scripts, Make compliments those.