命令行更新(安裝)
$ sudo gem update --system // 先更新gem夸政,國內(nèi)需要切換源
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
\*\*\* CURRENT SOURCES \*\*\*
https://ruby.taobao.org/
$ sudo gem install cocoapods // 安裝cocoapods
$ pod setup
補(bǔ)充:安裝的過程中遇到錯(cuò)誤:ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
解決方案:sudo gem install -n /usr/local/bin cocoapods 替換掉sudo gem install cocoapods
查看版本
$ pod --version
安裝第三方框架
//Podfile文件配置(OC)
target 'YourAppName' do
pod '三方框架' '~> 版本號'
end
//終端執(zhí)行
pod install
注意:編輯Podfile文件不要直接用文本編輯器秸歧,否則會報(bào)如下錯(cuò)誤(可以直接用xcode打開進(jìn)行編輯)
[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
使用cocoapods導(dǎo)入第三方類庫后頭文件沒有代碼提示在孝?
解決辦法: 選擇Target -> Build Settings 菜單雏蛮,找到\”User Header Search Paths\”設(shè)置項(xiàng)痛黎,新增一個(gè)值"${SRCROOT}",并且選擇\”Recursive\”
Snip20160519_1.png
在使用pod install安裝第三方庫的時(shí)候可能會卡在Updating local specs repositories
//解決辦法
把pod install 換成 pod install --verbose --no-repo-update
以上是使用cocoapod遇到的問題及解決方案的一個(gè)小總結(jié)
歡迎補(bǔ)充