一.安裝Cocoapods
安裝和使用cocoapods
教程總結(jié)>>>>>>>>>>>>>>>
gem sources --remove https://rubygems.org/
//等有反應(yīng)之后再敲入以下命令
gem sources -a http://ruby.taobao.org/
sudo gem update --system
gem sources -l
sudo gem install cocoa pods
二.升級(jí)ruby
可能在第一步操作的時(shí)候飘诗,提醒ruby等級(jí)過(guò)低,需要升級(jí),那么就在這里升級(jí)ruby吧
1页慷、安裝 RVM
curl -L get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile
2.用ram升級(jí)ruby
ruby -v
rvm list known
rvm install 2.2
升級(jí)成功后再查看版本
ruby -v
3.再次安裝cocoapods
sudo gem install cocoapods
進(jìn)行安裝
三.第三方庫(kù)導(dǎo)入
利用cocoapods給工程添加
vim Podfile
輸入需要的第三方庫(kù)育勺,例如
platform :ios, "7.0"
use_frameworks!
target '工程名' do
pod 'UMengSocialCOM', '~> 5.2.1'
end
關(guān)閉保存后終端輸入:
pod setup --verbose --no-repo-update
pod install
即可給工程里面添加第三方庫(kù)并且關(guān)聯(lián)
至此蔑水,大功告成啥箭!
2018-01-23 update
升級(jí)cocoapod
1.檢查當(dāng)前版本號(hào)
PishumdeMacBook-Pro:~ Pishum$ pod --version
1.2.1
當(dāng)前版本是1.2.1梳玫,現(xiàn)在最新版本是1.4.0(2018-01-23檢測(cè)版本)
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.如果上一步安裝報(bào)錯(cuò)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