关于CocoaPods安装

朋友公司电脑上没有CocoaPods,就帮他给安装了,结果出现一大堆问题。
1、装 Xcode 和 Command Line Tools
1.1)装Xcode就不说了,直接上mac的App Store下载就行了
1.2)Command Line Tools是在装完Xcode,在Xcode菜单 -> Preferences -> Downloads那安装。
貌似新版的Xcode里面不显示,那就直接在 终端 【应用程序 -> 实用工具 -> 终端】
[objc]
xcode-select –install
[/objc]

2、装Homebrew
2.1)终端输入以下命令
[objc]
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
[/objc]
2.2)关掉终端,重新打开,输入以下内容
[objc]
brew
[/objc]
2.3)看是否会提示-bash: brew: command not found,如果会请操作2.4流程,不会则进入第3步
2.4)点击桌面空白地方,cmd + shift + G,前往文件夹输入 /etc
2.5)找到 profile ,复制到桌面,进入编辑
2.6)在最后一行加入 PATH=/usr/local/bin:$PATH
2.7)保存后覆盖回去/etc/profile,然后重新打开终端试下brew

3、装RVM
3.1)终端,输入
[objc]
curl -L https://get.rvm.io | bash -s stable
[/objc]
3.2)等待安装后,输入以下命令,载入 RVM 环境
[objc]
source ~/.rvm/scripts/rvm
[/objc]
3.3)查询下版本,看安装是否成功
[objc]
rvm -v
[/objc]

4、装Ruby
4.1)终端输入,列出Ruby版本
[objc]
rvm list known
[/objc]
4.2)以2.0.0为例,终端输入
[objc]
rvm install 2.0.0
[/objc]
4.3)人品好的话,一下就过完直接看4.4。人品不好出现错误,看最后面的内容。
4.4)安装完后,可以在终端输入以下命令,查看已经安装的Ruby
[objc]
rvm list
[/objc]
4.5)设置Ruby默认版本
[objc]
rvm 2.0.0 –default
[/objc]
5.5)将源替换成淘宝的【https://ruby.taobao.org/】,操作如下
[objc]
$ gem sources –add https://ruby.taobao.org/ –remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org
# 请确保只有 ruby.taobao.org
$ gem install rails
[/objc]

——–分割线——–
人品不好的,出现错误已经解决方式:
错误一:Error running ‘requirements_osx_brew_update_system ruby-2.0.0-p643’
解决方式:
1、确认下你有Xcode和the Command Line Tools,以及Homebrew

错误二:Error running ‘requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl’
解决方法:
1、先在终端输入
[objc]
brew install autoconf automake libtool pkg-config apple-gcc42 libyaml readline libxml2 libxslt libksba openssl
[objc]
2、装完后输入[objc]rvm requirements[/objc]

错误三: brew install apple-gcc42 提示找不到之类的错误
解决方法:
1、终端输入[objc]brew install homebrew/dupes/apple-gcc42[/objc]

错误四:requirements_osx_brew_libs_install automake
解决方法:
1、终端输入[objc]brew install automake[/objc]

错误五:在执行brew install automake,提示You must `brew link autoconf` before automake can be installed
解决方法:
1、终端输入以下命令,{username}替换为当前系统用户名
[objc]
sudo chown -R {username} /usr/local
[/objc]
2、然后再执行brew link autoconf,之后如有错误按照提示操作即可。

错误六:用到gem,就提示bad interpreter: No such file or directory
主要原因:自己不小心改了用户名,导致路径错了。
解决方法:
1、终端输入以下命令
[objc]
brew update && brew install gmp && rvm reinstall 2.2.1
[/objc]
——–分割线——–

5、装CocoaPods
5.1)终端输入
[objc]sudo gem install cocoapods[/objc]
5.2)终端输入,看是否成功
[objc]pod –version [/objc]

相关链接,技术支持:
https://www.interworks.com/blog/ckaukis/2013/03/05/installing-ruby-200-rvm-and-homebrew-mac-os-x-108-mountain-lion
http://www.cnblogs.com/daguo/p/4097263.html
https://ruby.taobao.org/
http://stackoverflow.com/questions/15324590/rvm-install-ruby-1-9-3-missing-required-packages
http://stackoverflow.com/questions/16473115/error-running-requirements-osx-brew-libs-install-on-mac-10-7
http://stackoverflow.com/questions/16844826/error-when-trying-to-brew-link-autoconf/16844923

72 thoughts on “关于CocoaPods安装

发表评论

电子邮件地址不会被公开。