Cocoapods的作用就不再贅述了,個人文筆有限。
<h3>一、sudo gem install cocoapods(安裝Cocoapods)</h3>
先確認源 (gem sources -l)
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
<h5>可能出現的錯誤</h5>
a、 ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
rvm install 2.2.2 (更新ruby)
ruby -v (查看ruby版本)
b、當執行 pod install 命令時,錯誤:pod: command not found
可能原因: 升級OS X EI Capiton
解決:
卸載原有的CocoaPod sudo gem uninstall cocoapods
重新安裝cocoapod sudo gem install -n /usr/local/bin cocoapods
如果沒有權限執行pod,執行命令"sudo chmod +rx /usr/local/bin/",
賦予/usr/local/bin給予執行與讀取權限
轉載:http://www.lxweimin.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
轉載: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是獲取管理員權限,現在按照步驟輸入管理員密碼即可.
<h3>二、使用</h3>
安裝spec庫:pod spec create JJSKit
1、cd 進入項目根目錄
2、vim podfile
a: `i` 鍵入需要添加庫
b: `ESC` 退出編輯 ,`:wq` 冒號wq 保存并退出
3、pod install