Flutter開発でFirebaseを導入してiOS Simulatorを起動しようと思い、
flutter runコマンドを叩くと以下のようなエラーが出ました。
% flutter run
Multiple devices found:
AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
iPhone 14 Pro Max (mobile) • E1FD6F0F-BC19-491A-B103-0A0EF465CB91 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.110
[1]: AOSP on IA Emulator (emulator-5554)
[2]: iPhone 14 Pro Max (E1FD6F0F-BC19-491A-B103-0A0EF465CB91)
[3]: Chrome (chrome)
Please choose one (To quit, press "q/Q"): 2
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running pod install... 6.1s
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 `firebase_core` from `.symlinks/plugins/firebase_core/ios`
firebase_core: Using Firebase SDK version '10.2.0' defined in 'firebase_core'
-> Fetching podspec for `image_picker_ios` from `.symlinks/plugins/image_picker_ios/ios`
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
[!] CocoaPods could not find compatible versions for pod "firebase_core":
In Podfile:
firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Specs satisfying the `firebase_core (from `.symlinks/plugins/firebase_core/ios`)` dependency were found, but they required a higher minimum deployment target.
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `tap'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `unwind_for_conflict'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:682:in `attempt_to_activate'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/resolver.rb:94:in `resolve'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `load'
/usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `<main>'
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`.
Error running pod install
Error launching application on iPhone 14 Pro Max.
shimookakazuhiko@shimookakazuhikonoMacBook-Air my_app % cd ios
調べてみるとなんともこれは使っているパッケージのバージョンが変わった際に起こる可能性があるエラーのようです。
Error running pod installの解決方法
iosフォルダの中にある「podfile.lock」を削除し以下のコマンドを叩きます。
cd ios
pod install --repo-update
cd ../ //プロジェクトディレクトリに戻る
flutter clean
flutter run
通常はこれで上手くいくようです。
しかし、今回私の環境ではpod install をしたところ以下のようなエラー文が出ました。
[!] CocoaPods could not find compatible versions for pod "firebase_core":
In Podfile:
firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Specs satisfying the `firebase_core (from `.symlinks/plugins/firebase_core/ios`)` dependency were found, but they required a higher minimum deployment target.
[!] 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`.
パッケージの firebase_core のバージョンに対して、platformのiOSのバージョンが低いというエラーのようです。
CocoaPods could not find compatible versions for podの解決方法
iosフォルダの中にあるPodfileを編集します。
デフォルトではplatformのバージョンが9.0に設定されており、コメントアウトになっているので
platformのバージョンを上げてコメントアウトを無効にします。
# Uncomment this line to define a global platform for your project
// platform :ios, '9.0'
platform :ios, '12.0'
Podfileを編集したら再度以下のコマンドを叩いてみてください。
cd ios
pod install --repo-update
cd ../ //プロジェクトディレクトリに戻る
flutter clean
flutter run
これで上手くいきました。