2022-09-23 Exception: CocoaPods not installed or not in valid state.

升级xcode14
突然报错:Exception: CocoaPods not installed or not in valid state.

在 android studio 执行运行flutter项目

Launching lib/main.dart on xx in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: AG2MLGJ9xx
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.

Exception: CocoaPods not installed or not in valid state.

flutter doctor查看环境:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-arm, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!
pod --version
1.11.3

方法1:

重新安装cocoapods
具体方法:
删除cocoapods

gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall
gem sources -l
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com/
sudo gem install cocoapods

方法2:

到官方环境配置:
https://flutter.cn/docs/get-started/install/macos

m1电脑配置

sudo softwareupdate --install-rosetta --agree-to-license


sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer


sudo xcodebuild -runFirstLaunch



sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc


方法3:

在android studio 菜单,找到invalidate caches/ restart... 命令
重启android studio

image.png
Xnip2022-09-23_15-29-34.jpg

终极方法:

以上方法都没啥用

退出 android studio 使用命令打开 Android studio.app

open /Applications/Android\ Studio.app

最终OK:

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容