【Flutter】iOSエミュレータビルド時のエラー Exception: Error running pod install【解決方法】

はじめに

自分用のメモとして作成した記事のため説明が非常に荒くなっています。
ご了承ください。

現象

FlutterをiOSエミュレータでビルドした際にエラーが発生し、以下のメッセージが表示されました。

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

Exception: Error running pod install

対策

以下の手順通りに操作を行います。

  1. ios/Pods/, ios/Podfile, ios/Podfile.lockを削除(iOSリビルドにより再生成されるため、削除しても問題ありません。)
  2. flutter run
  3. https://qiita.com/tomono_22/items/1d71031d3832bb5a2cca【解決】のところ
  4. sudo arch -x86_64 gem install ffi ※M1 mac
  5. cd ios
  6. arch -x86_64 pod install --repo-update ※ M1 mac
  7. flutter clean
  8. flutter run

私の場合はこれでうまくいきました。

ダメな場合は、ios/Flutter/Debug.xcconfigの

#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

に置き換えてみてください。

参考

https://qiita.com/1440/items/836d8e19fd819a4ebbc4