LoginSignup
96
61

More than 1 year has passed since last update.

FlutterにFirebase(Firestore)を導入したら、iOSのビルドが遅くなった

Last updated at Posted at 2020-09-13

困ったこと

FlutterにFirebase(Firestore)を導入したら、iOSビルドがとても遅くなった。
元々1分くらいだったのが、10分くらいになってしまった。

解決法

2021/9/18時点の情報です。バージョンなどが古くなっている可能性があるので、公式ドキュメントを参照してく最新の情報を確認してください。

ios/Podfileに、下記を1行追加した。
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.26.0'

サンプル(抜粋)

ios/Podfile
target 'Runner' do
  use_frameworks!
  use_modular_headers!
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.6.0'
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

なぜ遅くなったのか?

公式ドキュメントによると、FirestoreのiOS SDKは500k行のC++で書かれているらしく、それを毎回コンパイルするため、時間がかかっているそう。
なので、事前にコンパイルした結果を、githubから取得するようにすることで、時間短縮しているということらしい。

Improve iOS Build Times#
Currently the Firestore iOS SDK depends on some 500k lines of mostly C++ code which can take upwards of 5 minutes to build in XCode. To reduce build times significantly, you can use a pre-compiled version by adding 1 line to your ios/Podfile inside your Flutter project;

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.6.0'

Add this line inside your target 'Runner' do block in your Podfile, e.g.:

あとがき

公式ドキュメントはしっかり読もうね、というお話でした。
この事象に困り、Flutter Firebase ビルド 遅い iOSなどのキーワードで結構ググりましたが、日本語と英語どちらもあまりヒットせず、みなさんちゃんと公式ドキュメント読んでいるんだなあと感じました。

反省。

96
61
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
96
61