背景
在多人开发时,将git上项目clone下来进行pod install后,发现sourceTree上未暂存文件中xxx/Podfile.lock文件有变动,看下图
- 从上图可以发现,由于本地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/
当前源地址为: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)
发现运行命令报错,原因是https://gems.ruby-china.org/地址找不到
用浏览器打开https://gems.ruby-china.org/,
上图中已经说明了域名已经更换了,那么换一下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
- 查看当前源
Frankkkk-2:~ aladin$ gem source -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com
至此,ruby源已经更新成功!
安装升级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.
安装过程中,报了权限错误 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
一下