升級CocoaPods到最新版本

背景

在多人開發(fā)時,將git上項目clone下來進(jìn)行pod install后,發(fā)現(xiàn)sourceTree上未暫存文件中xxx/Podfile.lock文件有變動,看下圖

第三方庫版本

CocoaPods版本

  • 從上圖可以發(fā)現(xiàn),由于本地cocoapods版本是1.6.1,git遠(yuǎn)端pod版本為1.7.1
  • 由于cocoapods版本不一致,同一份Podfile, pod install出來的第三方庫版本可能會不同
  • 第三方庫版本如何查看?通過Podfile.lock文件查看

升級pod版本

既然本地cocoapods版本比較低,那就得升級CocoaPods版本

  • 查看版本 pod --version
Frankkkk-2:~ aladin$ pod --version
1.5.3
  • 查看Ruby源地址
Frankkkk-2:~ aladin$ gem source -l
*** CURRENT SOURCES ***

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

當(dāng)前源地址為:https://gems.ruby-china.org/

  • 運(yùn)行sudo gem install cocoapods
Frankkkk-2:~ aladin$ 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)

發(fā)現(xiàn)運(yùn)行命令報錯,原因是https://gems.ruby-china.org/地址找不到
用瀏覽器打開https://gems.ruby-china.org/

ruby源地址報錯

上圖中已經(jīng)說明了域名已經(jīng)更換了,那么換一下ruby源就好了。

  • 更換ruby源,刪掉失效的源
Frankkkk-2:~ aladin$ gem sources --remove https://gems.ruby-china.org/
https://gems.ruby-china.org/ removed from sources

  • 添加可用的源
Frankkkk-2:~ aladin$ gem sources -a https://gems.ruby-china.com
https://gems.ruby-china.com added to sources

  • 查看當(dāng)前源
Frankkkk-2:~ aladin$ gem source -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com

至此,ruby源已經(jīng)更新成功!

安裝升級pod

運(yùn)行命令sudo gem install cocoapods

Frankkkk-2:~ aladin$ sudo gem install cocoapods
Password:
Fetching: cocoapods-core-1.7.1.gem (100%)
Successfully installed cocoapods-core-1.7.1
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.3.1.gem (100%)
Successfully installed cocoapods-trunk-1.3.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: xcodeproj-1.9.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

安裝過程中,報了權(quán)限錯誤 ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

解決辦法:運(yùn)行sudo gem install -n /usr/local/bin cocoapods

Frankkkk-2:~ aladin$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.9.0
Fetching: fourflusher-2.3.0.gem (100%)
Successfully installed fourflusher-2.3.0
Fetching: ruby-macho-1.4.0.gem (100%)
Successfully installed ruby-macho-1.4.0
Fetching: cocoapods-1.7.1.gem (100%)
Successfully installed cocoapods-1.7.1
Parsing documentation for xcodeproj-1.9.0
Installing ri documentation for xcodeproj-1.9.0
Parsing documentation for fourflusher-2.3.0
Installing ri documentation for fourflusher-2.3.0
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.7.1
Installing ri documentation for cocoapods-1.7.1
Done installing documentation for xcodeproj, fourflusher, ruby-macho, cocoapods after 5 seconds
4 gems installed

安裝完成后,再次確認(rèn)pod版本

Frankkkk-2:~ aladin$ pod --version
1.7.1

到此,終于將pod升級到最新的1.7.1版本了。

  • 最后,別忘了切到工程目錄下,重新pod install 一下
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。