Cocoapods的作用就不再贅述了,個人文筆有限舌胶。
<h3>一捆蜀、sudo gem install cocoapods(安裝Cocoapods)</h3>
先確認(rèn)源 (gem sources -l)
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
<h5>可能出現(xiàn)的錯誤</h5>
a、 ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
rvm install 2.2.2 (更新ruby)
ruby -v (查看ruby版本)
b幔嫂、當(dāng)執(zhí)行 pod install 命令時辆它,錯誤:pod: command not found
可能原因: 升級OS X EI Capiton
解決:
卸載原有的CocoaPod sudo gem uninstall cocoapods
重新安裝cocoapod sudo gem install -n /usr/local/bin cocoapods
如果沒有權(quán)限執(zhí)行pod,執(zhí)行命令"sudo chmod +rx /usr/local/bin/"履恩,
賦予/usr/local/bin給予執(zhí)行與讀取權(quán)限
轉(zhuǎn)載:http://www.reibang.com/p/6ff1903c3f11
c锰茉、[!] Unable to add a source with url https://github.com/CocoaPods/Specs.git
named master
.
解決方法:
i: cd ~/.cocoapods/repos
ii:git clone https://github.com/CocoaPods/Specs.git master
轉(zhuǎn)載:https://github.com/CocoaPods/CocoaPods/issues/4293
d、ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
只需要在命令前加上sudo,例如:sudo gem install json -v '1.8.2' 即可.
sudo是獲取管理員權(quán)限,現(xiàn)在按照步驟輸入管理員密碼即可.
<h3>二切心、使用</h3>
安裝spec庫:pod spec create JJSKit
1飒筑、cd 進入項目根目錄
2、vim podfile
a: `i` 鍵入需要添加庫
b: `ESC` 退出編輯 绽昏,`:wq` 冒號wq 保存并退出
3协屡、pod install