CocoPods更换Ruby源及升级版本

升级xcode11,项目适配iOS13,MJExtension报错,github上提示需要更新最新版本,使用终端 $pod search MJExtension 发现并无3.1.0及以上版本,而查看releases却发现已经更新到3.2.1,故需更新cocopods并更新本地库缓存,记录一下。
提示更新

1、查看当前cocopods版本

$ pod --version

fangcundeMacBook-Pro:~ fangcun$  pod --version
1.5.3

2、查看Ruby源

$ gem source -l

fangcundeMacBook-Pro:~ fangcun$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org

3、升级cocopods (需要输入密码,密码不会显示,输完回车)

$ sudo gem install cocoapods

fangcundeMacBook-Pro:~ fangcun$ sudo gem install cocoapods
Password:
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)

升级报错:Not Found 404,意思是当前源(https://gems.ruby-china.org)找不到了。在浏览器中浏览当前源,提示“服务域名更换公告”

源更换公告

解决:按公告提示更换源地址

3、删掉当前源

$ gem sources --remove https://rubygems.org/

说明:此处一直提示(source https://rubygems.org/ not present in cache),意思是没有删除源,我找了好多方法,都没用,一直是该提示。我后来没有进行处理,直接执行第4步,添加新的源,再查看,发现已经替换。提醒当遇到此类问题,不要纠结。

fangcundeMacBook-Pro:~ fangcun$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache

4、添加新源

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

fangcundeMacBook-Pro:~ fangcun$ gem sources --add https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources

5、查看当前源

$ gem source -l

fangcundeMacBook-Pro:~ fangcun$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

6、升级cocopods

$ sudo gem install cocoapods

Password:
Fetching: httpclient-2.8.3.gem (100%)
Successfully installed httpclient-2.8.3
Fetching: algoliasearch-1.27.1.gem (100%)
Successfully installed algoliasearch-1.27.1
Fetching: concurrent-ruby-1.1.5.gem (100%)
Successfully installed concurrent-ruby-1.1.5
Fetching: cocoapods-core-1.8.3.gem (100%)
Successfully installed cocoapods-core-1.8.3
Fetching: cocoapods-deintegrate-1.0.4.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.4
Fetching: cocoapods-downloader-1.2.2.gem (100%)
Successfully installed cocoapods-downloader-1.2.2
Fetching: cocoapods-trunk-1.4.1.gem (100%)
Successfully installed cocoapods-trunk-1.4.1
Fetching: molinillo-0.6.6.gem (100%)
Successfully installed molinillo-0.6.6
Fetching: atomos-0.1.3.gem (100%)
Successfully installed atomos-0.1.3
Fetching: nanaimo-0.2.6.gem (100%)
Successfully installed nanaimo-0.2.6
Fetching: xcodeproj-1.12.0.gem (100%)
Successfully installed xcodeproj-1.12.0
Fetching: fourflusher-2.3.1.gem (100%)
Successfully installed fourflusher-2.3.1
Fetching: ruby-macho-1.4.0.gem (100%)
Successfully installed ruby-macho-1.4.0
Fetching: cocoapods-1.8.3.gem (100%)
Successfully installed cocoapods-1.8.3
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.1
Installing ri documentation for algoliasearch-1.27.1
Parsing documentation for concurrent-ruby-1.1.5
Installing ri documentation for concurrent-ruby-1.1.5
Parsing documentation for cocoapods-core-1.8.3
Installing ri documentation for cocoapods-core-1.8.3
Parsing documentation for cocoapods-deintegrate-1.0.4
Installing ri documentation for cocoapods-deintegrate-1.0.4
Parsing documentation for cocoapods-downloader-1.2.2
Installing ri documentation for cocoapods-downloader-1.2.2
Parsing documentation for cocoapods-trunk-1.4.1
Installing ri documentation for cocoapods-trunk-1.4.1
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.12.0
Installing ri documentation for xcodeproj-1.12.0
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.8.3
Installing ri documentation for cocoapods-1.8.3
Done installing documentation for httpclient, algoliasearch, concurrent-ruby, cocoapods-core, cocoapods-deintegrate, cocoapods-downloader, cocoapods-trunk, molinillo, atomos, nanaimo, xcodeproj, fourflusher, ruby-macho, cocoapods after 23 seconds
14 gems installed

查看版本号
$ pod --version

fangcundeMacBook-Pro:~ fangcun$ pod --version
1.8.3

更新完成,修改MJExtension版本号并cd到项目进行pod install更新,解决报错问题。

注:有时候github的三方库的版本号与终端pod search 搜索出来的版本号对应不上,是因为本地cocopods缓存问题,此时需要执行 pod repo update 更新一下即可。

你可能感兴趣的:(CocoPods更换Ruby源及升级版本)