CocoaChina使用,以及一些坑

一、安装CocoaPods

1.首先更新gem到最新版本,在终端中输入:sudo gem update --system
2.删除自带的ruby镜像,终端输入:gem sources --remove https://rubygems.org/。
3.添加淘宝的镜像,终端输入:gem sources -a https://gems.ruby-china.org/(原来的淘宝镜像 https://ruby.taobao.org/已经不能用了)。
4.可以用gem sources -l 来检查使用替换镜像位置成功,结果应该只有 https://gems.ruby-china.org/ 才对。

CocoaChina使用,以及一些坑_第1张图片
Paste_Image.png

安装过程中可能出现证书错误的问题

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority to your local trusted store
ERROR: SSL verification error at depth 2: self signed certificate in certificate chain (19)
ERROR: Root certificate is not trusted (/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA)

解决方法可以参考文章cocopads /O=Digital Signature Trust

按照文章中的操作,需要更新ruby环境

1)首先要安装Homebrew终端输入这条命令即可/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2)安装rvm$ curl -L get.rvm.io | bash -s stable
3)装载rvm$ source ~/.rvm/scripts/rvm
4)安装2.3.0版本ruby$ rvm install 2.3.0
5)将2.3.0设为默认$ rvm use 2.3.0 --default
使用第3条命令,有可能找不到目录,在安装ruby的时候,会有一条提示安装到了哪个目录,

CocoaChina使用,以及一些坑_第2张图片
Paste_Image.png

5、安装CocoaPods,终端输入:sudo gem install cocoapods。
6、然后配置下CocoaPods,终端输入:pod setup。

CocoaPods使用

1、查找第三方库,比如查找SwiftyJSON,pod search SwiftyJSON
2、xcode集成cocoapods之后,可以使用命令
pod install 添加第三方库
pod update 更新第三方库的版本
3、如果遇到pod install或者pod update慢的问题,原因在于当执行以上两个命令的时候会升级CocoaPods的spec仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

更多内容,请参考文章

你可能感兴趣的:(CocoaChina使用,以及一些坑)