一.安装Cocoapods
安装和使用cocoapods
教程总结>>>>>>>>>>>>>>>
gem sources --remove https://rubygems.org/
//等有反应之后再敲入以下命令
gem sources -a http://ruby.taobao.org/
sudo gem update --system
gem sources -l
sudo gem install cocoa pods
二.升级ruby
可能在第一步操作的时候,提醒ruby等级过低,需要升级,那么就在这里升级ruby吧
1、安装 RVM
curl -L get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile
2.用ram升级ruby
ruby -v
rvm list known
rvm install 2.2
升级成功后再查看版本
ruby -v
3.再次安装cocoapods
sudo gem install cocoapods
进行安装
三.第三方库导入
利用cocoapods给工程添加
vim Podfile
输入需要的第三方库,例如
platform :ios, "7.0"
use_frameworks!
target '工程名' do
pod 'UMengSocialCOM', '~> 5.2.1'
end
关闭保存后终端输入:
pod setup --verbose --no-repo-update
pod install
即可给工程里面添加第三方库并且关联
至此,大功告成!
2018-01-23 update
升级cocoapod
1.检查当前版本号
PishumdeMacBook-Pro:~ Pishum$ pod --version
1.2.1
当前版本是1.2.1,现在最新版本是1.4.0(2018-01-23检测版本)
2.检查ruby源地址
PishumdeMacBook-Pro:~ Pishum$ gem source -l
*** CURRENT SOURCES ***
https://ruby.taobao.org/
3.更换新源
//移除旧的
PishumdeMacBook-Pro: Pishum$ gem sources --remove https://ruby.taobao.org/
https://ruby.taobao.org/ removed from sources
//添加新的
PishumdeMacBook-Pro: Pishum$ gem sources -a https://gems.ruby-china.org/ https://gems.ruby-china.org/ added to sources
//查看新源信息
PishumdeMacBook-Pro: Pishum$ gem source -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
4.开始安装
PishumdeMacBook-Pro: Pishum$ sudo gem install cocoapods
Password:
Fetching: cocoapods-core-1.4.0.gem (100%)
Successfully installed cocoapods-core-1.4.0
Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.2
Fetching: molinillo-0.6.4.gem (100%)
Successfully installed molinillo-0.6.4
Fetching: xcodeproj-1.5.4.gem (100%)
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
5.如果上一步安装报错Operation not permitted - /usr/bin/xcodeproj
PishumdeMacBook-Pro: Pishum$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.5.4 Fetching: ruby-macho-1.1.0.gem (100%)
Successfully installed ruby-macho-1.1.0 Fetching: cocoapods-1.4.0.gem (100%)
Successfully installed cocoapods-1.4.0
Parsing documentation for xcodeproj-1.5.4
Installing ri documentation for xcodeproj-1.5.4
Parsing documentation for ruby-macho-1.1.0
Installing ri documentation for ruby-macho-1.1.0
Parsing documentation for cocoapods-1.4.0
Installing ri documentation for cocoapods-1.4.0
3 gems installed
//查看版本
PishumdeMacBook-Pro: Pishum$ pod --version
1.4.0