🤖

【Flutter】エラーCocoaPods not installed. 〜が表示されiosビルドできない

2022/05/19に公開

概要

Flutter3にしたら、iOSでビルドできなくなったので解決方法のメモです。
(Flutter3はあまり関係ないかもです。)
またM1 macの場合はくまさんの記事の内容を最初にやると解決するかもしれません。

分かりづらい点や、誤り等ございましたら、ご指摘いただけるとありがたいです。
(Twitterにご連絡ください。)
この記事がどなたかの参考になれば幸いです。

環境

macOS Monterey(M1)
Android Studio (version 2021.2)

flutter doctor

terminal
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Android Studio (version 2020.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!

errorメッセージ

terminal
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

解決した手順

terminalで以下実行します。

terminal
flutter clean
flutter pub get
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.podspec
rm ios/Podfile
pod repo update

エラーが以下に変わります。

terminal
[!] CocoaPods could not find compatible versions for pod "Firebase/Firestore":
In Podfile:
cloud_firestore (from .symlinks/plugins/cloud_firestore/ios) was resolved to 3.1.15, which depends on
Firebase/Firestore (= 8.15.0)

さらにterminalで以下実行します。
(M1のみ。M1 macは最初にこれだけでよかったかも。)

terminal
sudo arch -x86_64 gem install ffi
arch -x86_64 pod repo update
arch -x86_64 pod install

これでビルドできるようになりました。

最後に

ここまで読んでいただきありがとうございました!

参考サイト

https://zenn.dev/hi_okuma/articles/1193c0b5df8a29
https://stackoverflow.com/questions/64443888/flutter-cocoapodss-specs-repository-is-too-out-of-date-to-satisfy-dependencies
https://stackoverflow.com/questions/67885055/flutter-error-running-pod-install-after-upgrading-flutter-version

Discussion