FlutterプロジェクトにFirestoreのcloud_firestore
パッケージを導入し、iOSシミュレーターをビルドしてみたら「ビルドが遅すぎる」と思った方向けにビルド時間を早くする方法を紹介します。
Podfile
に1行コードを追加するだけでビルド時間が早くなります。
目次
Firedtore導入後のiOSビルドを早くする方法
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'
上記コードをコピーしたら、Flutterプロジェクトを開き./ios/Podfile
のPodfile
を開きます。
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'
# ...
end
Podfile
を開いたら上記コードのようにtarget 'Runner' do
とend
の間に先ほどコピーしたコードをペーストし保存します。(インデントは空白2つ分)
これでiOSアプリのビルド時間が短くなっているはずです。
次のようなエラーが発生した場合の対処法
CocoaPods could not find compatible versions for pod "FirebaseFirestore":
In Podfile:
FirebaseFirestore (from `https://github.com/invertase/firestore-ios-sdk-frameworks.git`, tag `8.15.0`)
cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 3.4.3, which depends on
Firebase/Firestore (= 9.3.0) was resolved to 9.3.0, which depends on
FirebaseFirestore (~> 9.3.0)
iOSアプリをビルドして上記のようなエラーメッセージが表示された場合は、コード最後のtagtag => '9.3.0'
のバージョンが古くなっているのでバージョンを上げてみてください。
あわせて読みたい
【Flutter】CocoaPods could not find compatible versions for pod “FirebaseFirestore”:…
FlutterFire公式ドキュメントを参考にCloud Firestore導入していたところ、iOSアプリのビルド時間を短くするのに以下のコードが有効らしくドキュメントの指示通りコード…
一緒に読みたい
あわせて読みたい
【Flutter/Firestore】コレクションとは?手動でデータを操作して理解
Flutterでコードを使いながらCloud Firestoreのデータ管理(CRUD)を行っていく前に、まずは理解を深めるため手動でCloud Firestoreのデータを生成・追加していきます。 C…
あわせて読みたい
【Flutter/Firestore】データベースの作成
今回はFlutterアプリでデータの保存、同期、照会などができる「Cloud Firestore」のデータベースを作成する方法を紹介します。 【Firebaseで新規プロジェクトを作成】 …
参考