コンテンツへスキップ →

pod installするときに[!] CocoaPods could not find compatible versions for pod “cloud_firestore”:というエラーの対処法

Flutterのプロジェクトで$ pod installするときに上記のエラーが発生しました。

エラー内容

../ios on  master [$!]
$ pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_database: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '9.3.0' defined in 'firebase_core'
[!] 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.

[!] 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`.

対処法

Before

// ios/Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

After

// ios/Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

Podfileを修正します。

再度pod installをしたら、エラーがなくなりました。

エラーの原因

おそらくPodfileのplatformを指定していないとターゲットのバージョンが10未満なのでエラーになるのかと思います。

CocoaPods provides a default deployment target if one is not specified. The current default values are 4.3 for iOS, 10.6 for OS X, 9.0 for tvOS and 2.0 for watchOS.

https://guides.cocoapods.org/syntax/podfile.html#platform

iOSだと指定していないと、デフォルト値は4.3?とかなり低い。

Stackoverflowにエラーの原因を推測した回答が記載されてありました。

Updated answer for 2022. This is due to your minimum deployment target being less than iOS 10. According to the Firebase ios setup documentation, your project must target ios platform versions iOS 10 or later:

2022年の回答を更新しました。これは、あなたの最小デプロイメントターゲットがiOS 10未満であることが原因です。Firebase ios setup documentationによると、あなたのプロジェクトはiosプラットフォームのバージョンiOS 10以降をターゲットにする必要があります。

https://stackoverflow.com/a/72117620

一応上記の回答では10.0でも大丈夫そうですが、2022年時点では最低バージョンはiOS12.0でも十分かと思い指定しています。

参考

カテゴリー: Firebase Flutter