每次遇到xcode更新版本都会尴尬一次,心里就在想又该升级哈pod了,烦的很。之前也是看各种帖子来升级,虽然最后都成功了,但是每次都是搞很久。今天升级了xcode9,又出问题,又搞了几个小时。索性总结了一哈升级的时候的经验,给大家分享哈。
1、首先检查ruby环境,然后升级ruby环境(一般情况下是不需要升级ruby环境的)
ruby -v 先查看ruby版本,然后
(1)安装RVM
curl -L get.rvm.io | bash -s stable
(2)测试是否安装正常
rvm -v
2.用RVM升级Ruby
(1)查看当前ruby版本 ruby -v
(2)列出已知的ruby版本 rvm list known
(3)安装ruby 2.2.1(本人安装这个版本) rvm install 2.4.1
2、gem update--system 更新仓
3、更换ruby镜像
(1)检查当前镜像 gem sources -l
(2)移除当前镜像 gem sources --remove https://rubygems.org/(具体看你上一步检查的结果)
(3)更换新的镜像 gem sources -a https://gems.ruby-china.com
(4)检查新镜像是否安装成功 gem sources -l
4.安装CocoaPods
(1)旧版系统指令:
sudo gem install cocoapods
OS X EL Capitan升级后:
sudo gem install -n /usr/local/bin cocoapods
(2)下载标准配置文件 pod setup
这个过程等待很长,可以新开一个终端窗口,输入
cd ~/.cocoapods/ 到次路径下
du -sh * 查看文件夹大小
我的有800M,各位老铁慢慢等嘛。
(3)更新本地仓,执行:(非必须)
pod repo update
补充:更新过程中遇到的问题
1、# 忽略引入库的所有警告(强迫症者的福音啊)
inhibit_all_warnings!
2、更新了系统和xcode,pod失败,报错如下:/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version` ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n") (RuntimeError)
直接执行
xcode-select --install
3、提示安装cocopods成功,pod search 失败,提示报错:
pod search AFNetworking[!]Unable to find a podwithname,author,summary,or description matching`AFNetworking`
执行:git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
4、pod升级1.8以后,pod install失败或者pod search失败,提示报错:
[!] CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/f/3/7/VNHttpRequest/1.0.1/VNHttpRequest.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)
解决办法:
1. podfile文件中指定source源为master:
source 'https://github.com/CocoaPods/Specs.git'
2.移除trunk源
执行:pod repo remove trunk