Mac OS 10.12安装cocoapods

最近刚入手MBP,新机到手便迫不及待的开始安装各种工具。一个cocoapods彻底给我干蒙圈了,各种报错整整一天才安好,简直了。。总结如下希望对以后的朋友有帮助!

第一步:安装HomeBrew软件包管理工具,类似于ubuntu系统下的apt-get

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

第二步:重新安装curl使其支持openssl

brew install --with-openssl curl

因为在安装完cocoapods后进行setup会git clone cocoapods的远程仓库,容易出现下面的错误:

error: RPC failed; curl 18 transfer closed with outstanding read data remaining

第三步.Mac 10.12系统自带ruby版本是2.0,今天(17年2月15)为止ruby官网最新版本是2.4,我们就更新到这个版本。ruby的版本管理这里使用RVM

$ curl -sSL https://get.rvm.io | bash -s stable --ruby
$ source ~/.rvm/scripts/rvm
$ rvm --version
##输出:rvm 1.29.0 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]

##升级ruby至2.4.0并支持openssl
rvm reinstall 2.4.0 --with-openssl-dir=`brew --prefix openssl`

##安装完成之后查看
rvm list
##结果:=* ruby-2.4.0 [ x86_64 ]

第四步:安装cocoapods

sudo gem install cocoapods
pod setup

大功告成

PS:gem源taobao的已经不再进行维护,可切换至:https://gems.ruby-china.org/

你可能感兴趣的:(Mac OS 10.12安装cocoapods)