🐡

【Flutter/エラー】「Error running pod install」

2022/12/30に公開

具体的なエラー

Flutter 側

具体的なエラーとしては、cloud_firestore の upgrade 後、ios simurator でデバッグ開始時に、下記エラーが発生した。

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
  pod repo update

Error running pod install
Error launching application on iPhone 14 Pro Max.

native 側(ios 側)

より詳細を確認するため、ios ディレクトリへ移動し、下記を実行する。

cd ios
pod repo update
pod update

pod update を実行すると、下記のエラーが発生した。

xxx@xxx ios % pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
cloud_functions: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_analytics: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.3.0' defined in 'firebase_core'
firebase_dynamic_links: Using Firebase SDK version '10.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.

原因の究明

エラーメッセージに表示されている、.symlinks/plugins/cloud_firestore/ios 配下に、cloud_firestore.podspec というファイルが存在している。このファイル内で、deployment_target が指定されている。具体的には下記の通り。

①ios/.symlinks/plugins/cloud_firestore/ios/cloud_firestore.podspec
cat .symlinks/plugins/cloud_firestore/ios/cloud_firestore.podspec | grep deployment_target
  s.ios.deployment_target = '11.0'

一方、Podfile 内では、platform にバージョンを指定している。具体的には下記の通り。

②ios/Podfile
cat Podfile | grep platform
platform :ios, '10.0'

① と ② で指定されている「最小 deployment target のバージョン」の関係が、① > ② になっている。つまり、① では、11.0 以下のバージョンは対象外だが、② では 11.0 以下が対象外になっていない。という不整合な状態になっている。

対応

① =< ② となるように Podfile内の platform に指定するバージョンを変更する。

③ios/Podfile
cat Podfile | grep platform
platform :ios, '11.0'

応用

今回は、cloud_firestore でのエラー発生ケースを記載したが、cloud_firestore 以外の Flutter パッケージの場合でも、同様に対応可能と考えています。

Discussion