升级系统后发现 cocoapods 损坏,记录一下重新安装过程
执行命令:
sudo gem install -n /usr/local/bin cocoapods
报错:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220414-53747-cr18v2.rb extconf.rb
- 安装最新版ruby:
brew install ruby
- 根据提示执行下面命名:
我的是在.zshrc
文件,默认是在.bash_profile
。如果没有安装zsh
的话,就用默认的.bash_profile
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.zshrc
echo 'export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"' >> ~/.zshrc
- 安装 Cocoapods
sudo gem install -n /usr/local/bin cocoapods
ps: 如果网络不好,gem 无法更新的话,可以先修改 gem 源,再执行第 3 步
// 查看 gem 源是哪个
gem sources -l
// 移除官网的
gem sources --remove https://rubygems.org/
//添加源国内源
gem sources -a https://gems.ruby-china.com
网友评论