今天运行 Flutter 项目到 iPhone 手机时又碰到 CocoaPods
的报错
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:
sudo gem install cocoapods
CocoaPods not installed or not in valid state.
但其实我的 CocoaPods
是安装了的,之前运行到 iPhone 没问题。使用命令查看
gem list
不出意外可以找到 cocoapods
,如果没找到那你就需要先安装。像我这安装了还出现如上报错,而且之前运行是没问题的。我一般先抛出三板斧解决。
flutter clean
flutter pub get
cd ios && pod install && cd ..
上面命令逐条执行后再运行项目,结果我这边还报如上错误。好吧,三板斧没效果。但其实我的项目可以通过执行命令运行启动
flutter run
虽然命令启动也可以调试,但和点击按钮 Run 相比,总感觉差了点意思。
继续找问题,清除缓存,重启 Android studio – Invalidate Caches / Restart 。我这边尝试后,还是报如上一样错误。
继续关闭 Android studio,使用命令打开它,在终端使用
open /Applications/Android\ Studio.app
再点击按钮运行,OK 可以了。
本文由老郭种树原创,转载请注明:https://guozh.net/cocoapods-not-installed-or-not-in-valid-state/