CocoaPods 的安装(更新)、使用、删除

2016.03.17 08:57* 字数 456 阅读 9971评论 0喜欢 34
一、配置CocoaPods 的安装环境
去官网下载你想要安装ruby版本,下载ruby
解压ruby,然后cd到ruby路径

cd 路径
配置OpenSSL
配置openssl的时候,需要查看/usr/local/Cellar/openssl路径下对应的文件,例如我的就是1.0.2d_1
$ ./configure --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2d_1$ make$ sudo make install

Snip20170213_1.png
等待安装完成,进行安装cocoapods
查看源
$ gemsource-l
⚠️淘宝已经不支持,以下配置需要做修改
1.移除现有的Ruby默认源
gem sources --remove https://rubygems.org/

Snip20160316_1.png
~~2.使用新的源 ~~
$ gem source -ahttps://gems.ruby-china.org/
** 3.验证新源是否替换成功**
gem sources -l

4.安装CocoaPods
NO.1
sudo gem install cocoapods
备注:苹果系统升级 OS X EL Capitan 后改为 sudo gem install -n /usr/local/bin cocoapods

Snip20160316_5.png
NO.2
pod setup

Snip20160316_6.png
5.更新gem
sudo gem update --system

Snip20160316_7.png
到此cocoapods安装最新版本完成
二、如何使用CocoaPods
** 1.新建一个demo工程**

Snip20160316_8.png
** 2.在终端转到该工程路径下,创建一个Podfile文件**

Snip20160316_9.png
3.输入i进入编辑模式,编辑Podfile文件内容

Snip20160316_11.png
4.按下esc退出编辑模式,输入:wq保存退出

Snip20160316_12.png
5.输入pod install进行安装

Snip20160316_13.png
6.集成完毕

1.png
补充

Snip20160316_15.png

Snip20160316_16.png

Snip20160316_17.png
7.在原先的库中添加新的第三方库
使用终端 打开该工程下的Podfile文件

2.png
⚠️不再是pod install了,是pod update

3.png
之后更新成功,你就会看到你最新的库了

4.png
补充
如果你想要搜出确定的库,使用例如 pod search AFNetworking 命令

5.png
三、想要删除已有cocoapods集成的库,恢复原先工程
1.删除工程文件夹下的Podfile、Podfile.lock和Pods文件夹

Snip20160316_18.png
2.删除xcworkspace文件

Snip20160316_19.png
3.打开xcodeproj文件,删除项目中的libpods.a和Pods.xcconfig引用

Snip20160316_20.png
4.打开Build Phases选项,删除Check Pods Manifest.lock和Copy Pods Resources

Snip20160316_21.png
完成编译,无错通过
PS:如需转载请注明iOS小乔http://www.jianshu.com/users/f029d92cedc0/latest_articles
如果能够帮到你,请你打赏支持我的创作(请小乔喝杯饮料😁)
©小乔
网友评论