背景
在多人開發(fā)時,將git上項目clone下來進行pod install后锻霎,發(fā)現(xiàn)sourceTree上未暫存文件中xxx/Podfile.lock文件有變動,看下圖
- 從上圖可以發(fā)現(xiàn),由于本地cocoapods版本是1.6.1醉鳖,git遠端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/
- 運行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)運行命令報錯,原因是https://gems.ruby-china.org/地址找不到
用瀏覽器打開https://gems.ruby-china.org/纹因,
上圖中已經(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
運行命令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.恶耽。
解決辦法:運行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
安裝完成后,再次確認pod版本
Frankkkk-2:~ aladin$ pod --version
1.7.1
到此颜启,終于將pod升級到最新的1.7.1版本了偷俭。
- 最后,別忘了切到工程目錄下缰盏,重新
pod install
一下