Podfileの概要とエラー対処まとめ 【Flutter / Dart / CocoaPods】
はじめまして、ますみです!
株式会社Galirage(ガリレージ)という「生成AIに特化して、システム開発・アドバイザリー支援・研修支援をしているIT企業」で、代表をしております^^
Flutterでflutter run
やflutter build ios
やpod install
などのコマンドを実行した際、podsがうまく入らないことがあります。
私はここで少しだけ苦戦したため、他の困っている方々に向けてログを残します🦅
CocoaPodsとは?
CocoaPodsとは、iOSのスマホアプリやmacOSのデスクトップアプリなどを作る際の「ライブラリ管理をしてくれるツール」です。余談ですが、macOSに初期搭載されているrubyのパッケージ(gem)の一つです。また、pod
はCocoaPodsのコマンドを実行する際のコマンドになります(一つ一つのライブラリのことも指します)。
PodfileとPodfile.lockとは?
CocoaPodsにおけるPodfileとPodfile.lockの意味をまず確認しましょう。
Podfileは「ライブラリのバージョン指定などをするファイル」です。
Podfile.lockは「ロック(固定)されたバージョンの情報が格納されているファイル」です。.lock
ファイルは、pod init
やpod install
時に自動生成されます。
エラー内容と対処法
具体的なエラー内容は、以下の二つです。
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'
最後に
最後まで読んでくださり、ありがとうございました!
この記事を通して、少しでもあなたの学びに役立てば幸いです!
宣伝:もしもよかったらご覧ください^^
『AIとコミュニケーションする技術(インプレス出版)』という書籍を出版しました🎉
これからの未来において「変わらない知識」を見極めて、生成AIの業界において、読まれ続ける「バイブル」となる本をまとめ上げました。
かなり自信のある一冊なため、もしもよろしければ、ご一読いただけますと幸いです^^
Discussion