1. 安装
a. 查看源
i. gem sources -l
b. 删除源
i. sudo gem sources -r https://rubygems.org/
c. 设置源
i. sudo gem sources -a https://ruby.taobao.org --- 这里要换成新的源!!!
添加国内最新的源 ruby-china
sudo gem sources -a https://gems.ruby-china.org
d. 安装cocoaPad
--> sudo gem install cocoapods -->
or ->升级gem sudo gem update --system 也是正常的
or ->安装CocoaPods执行正常:sudo gem install -n /usr/local/bin cocoapods
e. 设置
i. pod setup
2. cocoaPods使用
a. 搜索 <可略过>
i. pod search SDWebImage
b. 切换到项目的根目录 <可略过>
i. echo "pod' SDWebImage'" >Podfile
c. 安装
i. pod install
d. 升级
i. pod update
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.
rb:245:
in
'mkdir'
: Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal
-darwin-14 (Errno::EACCES)
1. 分别执行下面命令卸载cocoapods和xcodeproj,如果你的机器上面有多个版本,选择All versions卸载
|
$ sudo gem uninstall cocoapods $ sudo gem uninstall xcodeproj |
2. 分别执行下面命令安装xcodeproj和cocoapods
|
$ sudo gem install xcodeproj $ sudo gem install cocoapods |
接下来尝试执行pod install,如果您还遇到下面的错误:
1
2
|
Error loading the plugin with path '/Library/Ruby/Gems/2.0.0/gems/cocoapods-plugins-0.3.1/lib/cocoapods_plugin.rb' .
Errno::EACCES - Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14 |
运行命令$ gem update --system即可。
查看当前安装了哪些版本:
gem list --local | grep cocoapods
解决 cocoapods安装路径问题:
解决方法:在路径里面手动添加/usr/local/bin
如果不行就在终端执行更改命令:
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods
sudo chmod +rx /usr/local/bin/
// -------------------------------------------
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
报上边这错误 执行下面的代码:
sudo gem install -n /usr/local/bin cocoapods
SuperdeMacBook-Pro:.cocoapods super$ sudo gem install cocoapods
SuperdeMacBook-Pro:.cocoapods super$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.1.0
Fetching: cocoapods-1.0.1.gem (100%)
Successfully installed cocoapods-1.0.1
Parsing documentation for xcodeproj-1.1.0
Installing ri documentation for xcodeproj-1.1.0
Parsing documentation for cocoapods-1.0.1
Installing ri documentation for cocoapods-1.0.1
2 gems installed
SuperdeMacBook-Pro:.cocoapods super$
【链接】cocoapods的安装遇到Errorinstallingpods:activesupport
http://www.cnblogs.com/gongyuhonglou/p/5801681.html
//-----------------------------------------------遇到的另外一个报错
ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: cocoapods requires claide (< 2.0, >= 1.0.1), cocoapods-downloader (< 2.0, >= 1.1.2), cocoapods-trunk (< 2.0, >= 1.1.1), molinillo (~> 0.5.3), xcodeproj (< 2.0, >= 1.4.0), fourflusher (~> 2.0.1)
解决的链接:http://blog.csdn.net/miao_em/article/details/53282730
解决的命令:sudo gem update --system
// ----------------------------------------------遇到的另外一个报错
添加国内ruby源 gem sources --add https://gems.ruby-china.org
报错:
Error fetching https://gems.ruby-china.org/:
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
原因是 ruby-china 更换了域名
https://gems.ruby-china.com
命令替换为 gem sources --add https://gems.ruby-china.com 解决