cocoapod安装(2020最新)
参考网址:https://www.jianshu.com/p/f43b5964f582
1.ruby -v 查看ruby版本(我的是:ruby 2.6.3p62)
如果要更新,还得更新rvm环境,看上面的参考链接
2.切换源:
sudo gem update --system (这句执行失败貌似也不用管)
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
gem sources -l (查看当前源)
3.配置git的相关域名,防止安装过程遇到请求超时:
根据域名查询ip地址(将查到的ip地址,取第一个,与下面的对应放入hosts文件):
https://site.ip138.com/github.com/
更改hosts文件:
sudo vim /etc/hosts (保存:ESC :wq)
[异常结束的解决:sudo rm -f /etc/.hosts.swp]
hosts尾部添加这些域名:
75.126.164.178 github.global.ssl.fastly.net
140.82.114.4 github.com
185.199.108.153 assets-cdn.github.com
151.101.108.133 avatars0.githubusercontent.com
151.101.108.133 avatars1.githubusercontent.com
更改后可以看下是否更改,以及是否能ping通:
ping github.com
退出ping: ctrl+z
4.安装cocoapoda
sudo gem install -n /usr/local/bin cocoapods
********过程中遇到的一些报错:
1.安装homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fatal: unable to access 'https://github.com/Homebrew/brew/': Failed to connect to github.com port 443: Operation timed out
解决:
查询是否使用代理:
git config --global http.proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global http.proxy "127.0.0.1:1080"
git config --global https.proxy http://127.0.0.1:1080
2.遇到Command Line Tools没有找到:
多个xcode这样处理:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
还是报错,注意看是否报错的版本跟安装的不一样,如果不一样就去官网下载一个对应的版本安装
3.pod setup 新系统执行很快,完成后~/.cocoapods/repos/master文件夹没有生成
方案一 (此方法最好选择晚上12点后,亲测晚上1点成功):
git clone https://github.com/CocoaPods/Specs.git master
方案二(SSH方式下载,也就是将https改成git,需要去git官网配置公钥,亲测早上7点成功):
git clone git://github.com/CocoaPods/Specs.git master
查看本地是否生成过公钥:
cd ~/.ssh
ls
authorized_keys2 id_dsa(私钥) known_hosts config id_dsa.pub(公钥)
生成公钥和私钥:
ssh-keygen -t rsa -C "your_email@youremail.com"
将公钥配置到git官网:id_rsa.pub
验证公钥是否正常:
ssh -T git@github.com
Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.
具体配置可参考此链接:https://www.cnblogs.com/akidongzi/p/8366535.html