Swift中CocoaPods的使用

2016-05-31  本文已影响124人  寒桥

一、概要

iOS开发时,项目中会引用许多第三方库,CocoaPods 可以用来方便的统一管理这些第三方库。

二、安装

要使用CocoaPods,那就要下载安装它,而下载安装CocoaPods需要Ruby环境

gem sources --remove https://rubygems.org/ 
gem sources -a https://gems.ruby-china.org/ 
gem sources -l  (用来检查使用替换镜像位置成功)
sudo gem install -n /usr/local/bin cocoapods 

出现 1 gem installed说明已经安装成功

Podfile文件
* 再次执行 `pod install --no-repo-update` 即可

现在打开项目点击 XXXXX.xcworkspace,cocoapod安装完成

如果需要添加新的第三方库,只需要在Podfile文件下添加即可,然后执行pod install --no-repo-update

三、安装过程遇到的报错以及解决方式(持续更新...)

1.报SSL错误

ERROR:  SSL verification error at depth 2: unable to get local issuer certificate (20)
ERROR:  You must add /C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority to your local trusted store
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)
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod

解决方式:

sudo gem install -n /usr/local/bin cocoapods
上一篇 下一篇

猜你喜欢

热点阅读