iOS依赖库管理工具cocoapods升级

2018-09-07  本文已影响33人  笑破天

主要步骤是更新cocoapods版本和修改gem源,然后可能会对gem进行更新

1、查看cocoapods版本
pod --version
2、更新cocoapods
sudo gem install -n /usr/local/bin cocoapods
3、查看gem版本
gem --version
gem -v
4、更新gem(可跳过)
sudo gem update --system 

直接使用gem update --system命令会遇到目录权限不够的问题,报错如下

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

直接使用sudo gem update --system命令也会遇到目录权限不够的问题,报错如下

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

修改文件权限之后仍然报错

sudo chmod 777 /Library/Ruby/Gems/2.3.0
gem update --system
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Library/Ruby/Gems/2.3.0/gems/rubygems-update-2.7.7/.autotest

博主一直未更新成功,之后发现用2.7.6版本也可以走下去,遂跳过。

5、修改gem源

进行gem更新和cocoapods更新时会遇到404错误,这是因为gem源不对所致,需要更改gem源,最开始是用的淘宝的源,后来换为中国镜像.org源,现在的源是中国镜像的.com源。可点击官网查看

gem源更改公告.jpg

更新gem报404错误和更新cocoapods报404错误提示

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

修改gem源命令

gem sources --add https://gems.ruby-china.com/ --remove https://gems.ruby-china.org/

查看gem源命令

gem sources -l
上一篇 下一篇

猜你喜欢

热点阅读