Podfileの概要とエラー対処まとめ 【Flutter / Dart / CocoaPods】
はじめまして、ますみです!
Flutterでflutter run
やflutter build ios
やpod install
などのコマンドを実行した際、podsがうまく入らないことがあります。
私はここで少しだけ苦戦したため、他の困っている方々に向けてログを残します🦅
CocoaPodsとは?
CocoaPodsとは、iOSのスマホアプリやmacOSのデスクトップアプリなどを作る際の「ライブラリ管理をしてくれるツール」です。余談ですが、macOSに初期搭載されているrubyのパッケージ(gem)の一つです。また、pod
はCocoaPodsのコマンドを実行する際のコマンドになります(一つ一つのライブラリのことも指します)。
https://qiita.com/satoken0417/items/479bcdf91cff2634ffb1
PodfileとPodfile.lockとは?
CocoaPodsにおけるPodfileとPodfile.lockの意味をまず確認しましょう。
Podfileは「ライブラリのバージョン指定などをするファイル」です。
Podfile.lockは「ロック(固定)されたバージョンの情報が格納されているファイル」です。.lock
ファイルは、pod init
やpod install
時に自動生成されます。
https://note.com/iga34engineer/n/n12a5404543e1
エラー内容と対処法
具体的なエラー内容は、以下の二つです。
Please specify a platform
と優しく怒られる 😇
1. Error output from CocoaPods:
↳
[!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was
specified. Please specify a platform for this target in your Podfile. See
`https://guides.cocoapods.org/syntax/podfile.html#platform`.
- こちらのバグは、
ios/Podfile
の2行目の// platform :ios, '9.0'
がコメントになっていることが原因のバグです。 - そのため、コメントを外すと、エラーは消えるため、以下のように
ios/Podfile
を編集しましょう。
# Uncomment this line to define a global platform for your project
- // platform :ios, '9.0'
+ platform :ios, '9.0'
- もしも
ios/Podfile.lock
がある場合は、以下のコマンドも実行しましょう。
% cd ios
% rm Podfile.lock
% sudo gem install cocoapods
Passwords: {ログイン用のパスワードを入力}
% pod repo update
% pod update
% pod install
CocoaPods could not find compatible versions for pod "cloud_firestore"
と少し厳しめに怒られる 😲
2. % flutter build ios
Running "flutter pub get" in flutter_project... 858ms
Building dev.masumi.flutterProject for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: F39HGSSES
Running pod install... 1,513ms
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
cloud_firestore: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
-> Fetching podspec for `cloud_functions` from `.symlinks/plugins/cloud_functions/ios`
cloud_functions: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
-> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
firebase_auth: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
-> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
firebase_core: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
-> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in
repo update
[!] CocoaPods could not find compatible versions for pod "cloud_firestore":
In Podfile:
cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but
they required a higher minimum deployment target.
- このエラーは、
cloud_firestore
がios: 9.0
に対応していないということがエラーでした。 -
Podfile
のiosのバージョンを上げるとpod install
のプロセスを通過できます。
# Uncomment this line to define a global platform for your project
- platform :ios, '9.0'
+ platform :ios, '12.0'
最後に
最後まで読んでくださり、ありがとうございました!
この記事を通して、少しでもあなたの学びに役立てば幸いです!
おまけ
エンジニアの仲間(データサイエンティストも含む)を増やしたいため、公式LINEを始めました🎉
「一緒に仕事をしてくれる方」「友だちとして仲良くしてくれる方」は、友だち追加をしていただけますと嬉しいです!(仲良くなった人たちを集めて、「ボードゲーム会」や「ハッカソン」や「もくもく会」もやりたいなと考えています😆)
とはいえ、みなさんにもメリットがないと申し訳ないので、特典を用意しました!
友だち追加後に、アンケートに回答してくれた方へ「エンジニア図鑑(職種20選)」のPDFをお送りします◎
Discussion