CocoaPods install
flutter 项目踩坑记录,运行公司的 flutter 项目,一直报错:CocoaPods not installed. Skipping pod install.
这一段提示是告诉我们,电脑没有安装 CocoaPods 。如何知道电脑有没有安装?可以在Terminal执行下面的指令:
gem list
如果执行完后没有红色框框的内容,那说明确实没有安装。那么需要执行 CocoaPods 安装命令:
sudo gem install cocoapods
需要注意的是,安装完成之后,需要重启编辑器,command + q 彻底关闭进程之后,再次打开。如果你使用的是 Android Studio,也可以在 Terminal 中执行以下指令:
open /Applications/Android\ Studio.app
该指令会打开 Android Studio 应用,选择你想要运行的项目运行就可以了。
cocoapods 安装失败 ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.
在安装 cocoapods 时,会有安装失败的情况, 报错如下:
解决办法:先安装 homebrew,再更新 Ruby,再安装 cocoapods
homebrew 相关命令
安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
卸载
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
查看版本
brew -v
更新版本
brew update
安装软件列表
brew ls
ruby 相关命令:
更新ruby
brew install ruby
查看版本
ruby -v
配置环境变量, 该命令在安装完 ruby 之后会有提示
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
CocoaPods 相关命令
安装
sudo gem install cocoapods
查看版本
pod --version
卸载
sudo gem uninstall cocoapods
查看已安装与 CocoaPods 相关插件
gem list --local | grep cocoapods
逐个 卸载相关插件
sudo gem uninstall cocoapods-core
...
cocoapods 已安装,flutter run 可以执行,点击调试按钮报错:
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Warning: CocoaPods is installed but broken. Skipping pod install.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
For more info, see https://github.com/flutter/flutter/issues/14293.
To re-install:
sudo gem install cocoapods
CocoaPods not installed or not in valid state.
命令执行集合:
sudo gem list
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem install cocoapods
pod setup
brew link --overwrite cocoapods
brew unlink cocoapods && brew link cocoapods // 取消链接并再次链接
重启 IDE,重试。