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.jianshu.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