cocoapods的安装
1、升级Ruby环境
终端输入:$ gem update --system
此时若出现:ERROR:While executing gem......(Gem::FilePermissionError)
you don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
这是因为你没有权限去升级Ruby
此时输入:$ sudo gem update --system
2、 更换 Ruby镜像
(1)、 删除原先的源
终端输入:$ gem sources --remove https://rubygems.org/
(2)、添加新的源
终端输入:$ gem sources -a https://gems.ruby-china.org
(3)、查看当前镜像
终端输入:$gem sources -l
如果结果是
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
说明添加成功,否则继续执行$ gem source -a https://gems.ruby-china.com/来添加
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
说明添加成功,否则继续执行$ gem source -a https://gems.ruby-china.com/来添加
3、安装CocoaPods
终端输入:$ sudo gem install cocoapods
如果出现下图1所示的错误:
图1
说明没有权限,需要输入
终端输入:$ sudo gem install -n /usr/local/bin cocoapods
安装成功如下图2所示:
图2
如果出现错误:
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
macdeMBP:test-CocoaPods mac$ sudo gem install -n /usr/local/bin cocoapods
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
macdeMBP:test-CocoaPods mac$ sudo gem install -n /usr/local/bin cocoapods
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
出现这个问题,需要更新Ruby环境
【1】安装Homebrew
终端输入:$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
【2】安装rvm
【2】安装rvm
终端输入:$ curl -L get.rvm.io | bash -s stable
【3】装载rvm
终端输入:$ source ~/.rvm/scripts/rvm
【4】重新安装cocoapods
4、终端输入:$pod setup
若出现以下错误请参照该图所示: