1.升级Ruby环境git
gem -vgithub
gem update --systemxcode
若是没有权限去升级Ruby ?就输入ruby
sudo gem update --systemapp
2.换掉Ruby镜像code
首先移除现有的Ruby镜像rem
gem sources --remove https://rubygems.org/get
添加国内最新镜像源it
gem source -a https://gems.ruby-china.org/io
查看当前镜像
gem sources -l
3.安装CocoaPods
sudo gem install cocoapods
若是报错
sudo gem install -n /usr/local/bin cocoapods
4.初始化repos文件
pod repo add master https://github.com/CocoaPods/Specs.git
报错用这个
pod setup
5.安装过程当中出现报错
报错类型1:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com
缘由多是:github.com没有被主机给解析
解决方法:在本地手动指定github.com的IP地址
编辑文件etc/hosts
sudo vi /etc/hosts
添加github的地址
::1 localhost
192.30.255.112 github.com
报错类型2:
[!] /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master --depth=1
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com
缘由多是:安装多个Xcdoe,xcode路径问题
解决方法:sudo xcode-select -switch /Applications/Xcode.app/
在终端里输入下方命令能够知道Xcode的路径:
xcode-select -p