【1分で解決】CocoaPods could not find compatible versionsエラー

【1分で解決】CocoaPods could not find compatible versionsエラー

flutter runやpod installでFirebase/CoreOnlyエラー

flutter run or pod installすると以下のエラーが出てビルドできない…

Firebase/CoreOnly バージョンが CocoaPods の spec リポジトリに存在しない、つまり手元のポッドのリポジトリが古くて必要なバージョンを見つけられないというエラーです。

% pod install
....
[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In snapshot (Podfile.lock):
    Firebase/CoreOnly (= 11.10.0)

  In Podfile:
    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 3.15.2, which depends on
      Firebase/CoreOnly (= 11.15.0)

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/CoreOnly` inside your development pod `firebase_core`.
   You should run `pod update Firebase/CoreOnly` to apply changes you've made.

解決方法

iosディレクトリで以下を実行して解消。

% sudo arch -x86_64 gem install ffi
% rm -rf Podfile.lock
% arch -x86_64 pod repo update
% arch -x86_64 pod install

ffi は CocoaPods の一部である Ruby gems の依存パッケージです。

これが正しく動いていないと CocoaPods が内部でエラーを出す可能性があります。

特に M1/M2 環境では ffi のネイティブビルドが ARM だと CocoaPods と不整合を起こす場合があり、それを避けるために x86_64 でインストールします。

記事を書いた人

Matsuura

エンジニア

Matsuura

Anycloudでエンジニアしてます!FlutterやWebフロント、TypeScriptでバックエンド対応。