cocoapds安装

安装失败大部分原因是ruby版本过低:


命令行中显示:

$ sudo gem install -n /usr/local/bin cocoapods

ERROR:  Error installing cocoapods:

activesupport requires Ruby version >= 2.2.2.



查看ruby版本后发现版本过低

$ ruby -v

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]



安装过程如下:

1升级ruby

傻瓜式的步骤:

1、安装 RVM

RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)

[ruby]  view plain  copy
  1. $ curl -L get.rvm.io | bash -s stable  

等待一段时间后就可以成功安装好 RVM。(等着就好了,不到10秒吧.)

[ruby]  view plain  copy
  1. $ source ~/.bashrc  
  2. $ source ~/.bash_profile  

测试是否安装正常,(以上两个命令行敲了不会显示什么,但是需要敲。


[ruby]  view plain  copy
  1. rvm -v  

显示版本,会出现下边的样子(当然版本会由于时间的关系显示的不一样,下边的除了版本数不一定一样,其他的都是套路)

rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]


2、用RVM升级Ruby

主要是第五行,看一下当前的版本有哪些?然后第七行安装个版本高点的(老板,来个2.2的)~

当然如果你看到这篇文章的时候版本可能会更高,你就别选2.2的了,版本能多高就多高吧少年.

[ruby]  view plain  copy
  1. #查看当前ruby版本  
  2. $ ruby -v  
  3. ruby 2.0.0  
  4. #列出已知的ruby版本  
  5. $ rvm list known  
  6. #安装ruby 1.9.3  
  7. $ rvm install 2.2  

控制台打印出:


Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.11/x86_64/ruby-2.2.4.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx.

About to install Homebrew, press `Enter` for default installation in `/usr/local`,

type new path if you wish custom Homebrew installation (the path needs to be writable for user)


(1)直接按回车(安装Homebrew):

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/doc/homebrew

/usr/local/share/man/man1/brew.1

/usr/local/share/zsh/site-functions/_brew

/usr/local/etc/bash_completion.d/brew

==> The following directories will be made group writable:

.......



Homebrew安装完后:

==> Homebrew has enabled anonymous aggregate user behaviour analytics

Read the analytics documentation (and how to opt-out) here:

  https://git.io/brew-analytics

Installing requirements for osx.

Updating system.....

Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl.....\


(2)直接按回车,开始下载按钮ruby2.2.4:

...

Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.

Requirements installation successful.

Installing Ruby from source to: /Users/apple/.rvm/rubies/ruby-2.2.4, this may take a while depending on your cpu(s)...

ruby-2.2.4 - #downloading ruby-2.2.4, this may take a while depending on your connection...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 12.7M  100 12.7M    0     0   229k      0  0:00:56  0:00:56 --:--:--  242k

ruby-2.2.4 - #extracting ruby-2.2.4 to /Users/apple/.rvm/src/ruby-2.2.4....

ruby-2.2.4 - #applying patch /Users/apple/.rvm/patches/ruby/2.2.4/fix_installing_bundled_gems.patch.


大概10s后,ruby2.2.4安装完成。

然后查看版本:

命令:ruby -v

ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]


(3)进一步升级ruby:

命令:sudo gem update --system

Updating rubygems-update

Fetching: rubygems-update-2.6.6.gem (100%)

Successfully installed rubygems-update-2.6.6

Parsing documentation for rubygems-update-2.6.6

Installing ri documentation for rubygems-update-2.6.6

Installing darkfish documentation for rubygems-update-2.6.6

Done installing documentation for rubygems-update after 26 seconds

Parsing documentation for rubygems-update-2.6.6

Done installing documentation for rubygems-update after 0 seconds

Installing RubyGems 2.6.6

RubyGems 2.6.6 installed

Parsing documentation for rubygems-2.6.6

Installing ri documentation for rubygems-2.6.6


=== 2.6.6 / 2016-06-22


升级到的2.6.6版本


3.切换数据源:

命令:

gem source --remove https://rubygems.org/

gem source -a https://ruby.taobao.org/

gem source -l



4.安装cocoapods:

命令:sudo gem install cocoapods

等待安装完成吧。。。。





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值