CocoaPods安装

来源:互联网 发布:linux 解压缩gz 编辑:程序博客网 时间:2024/06/05 14:17

查看此博客还不会安装CocoaPods的可以随时来联系我:留言


1.安装   

    在安装CocoaPods之前,首先要在本地安装好Ruby环境。下面介绍在Mac中安装好Ruby环境。(标注:我是安装在Mac OS X 10.11.5上 

     下面的使用说明中,带有 $ 打头的表示需要在控制台(终端)下面执行(不包括 $ 符号),复制到终端在控制台执行就可以了。

步骤1 - 安装 RVM

    $ curl -L https://get.rvm.io | bash -s stable

           期间可能会问你sudo管理员密码,以及自动通过homebrew安装依赖包,等待一段时间后就可以成功安装好 RVM。


安装完以后会出现如下文本:

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

                                 Dload  Upload   Total   Spent    Left  Speed

100   184  100   184    0     0     48      0  0:00:03  0:00:03 --:--:--    48

100 22865  100 22865    0     0   4063      0  0:00:05  0:00:05 --:--:-- 17821

Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz

Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc

Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc',

but no GPG software exists to validate it, skipping.


Installing RVM to /Users/jq/.rvm/

    Adding rvm PATH line to /Users/jq/.profile /Users/jq/.mkshrc /Users/jq/.bashrc /Users/jq/.zshrc.

    Adding rvm loading line to /Users/jq/.profile /Users/jq/.bash_profile /Users/jq/.zlogin.

Installation of RVM in /Users/jq/.rvm/ is almost complete:


  * To start using RVM you need to run `source /Users/jq/.rvm/scripts/rvm`

    in all your open shell windows, in rare cases you need to reopen all shell windows.


# jq,

#

#   Thank you for using RVM!

#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!

#

# ~Wayne, Michal & team.




In case of problems: https://rvm.io/helpandhttps://twitter.com/rvm_io

    $  source ~/.rvm/scripts/rvm

           检查一下是否安装正确

    $ rvm -v  

安装完以后会出现如下文本

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



 步骤2 - 用 RVM 安装 Ruby 环境

         列出已知的ruby版本

       $ rvm list known


安装完以后会出现如下文本:

# MRI Rubies

[ruby-]1.8.6[-p420]

[ruby-]1.8.7[-head] # security released on head

[ruby-]1.9.1[-p431]

[ruby-]1.9.2[-p330]

[ruby-]1.9.3[-p551]

[ruby-]2.0.0[-p648]

[ruby-]2.1[.8]

[ruby-]2.2[.4]

[ruby-]2.3[.0]

[ruby-]2.2-head

ruby-head


# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2


# JRuby

jruby-1.6[.8]

jruby-1.7[.23]

jruby[-9.0.5.0]

jruby-head


# Rubinius

rbx-1[.4.3]

rbx-2.3[.0]

rbx-2.4[.1]

rbx[-2.5.8]

rbx-head


# Opal

opal


# Minimalistic ruby implementation - ISO 30170:2012

mruby[-head]


# Ruby Enterprise Edition

ree-1.8.6

ree[-1.8.7][-2012.02]


# GoRuby

goruby


# Topaz

topaz


# MagLev

maglev[-head]

maglev-1.0.0


# Mac OS X Snow Leopard Or Newer

macruby-0.10

macruby-0.11

macruby[-0.12]

macruby-nightly

macruby-head


# IronRuby

ironruby[-1.1.3]

ironruby-head


       可以选择现有的rvm版本来进行安装(下面以rvm 2.0.0版本的安装为例)

  $ rvm install 2.0.0    

        同样继续等待漫长的下载,编译过程,完成以后,Ruby, Ruby Gems 就安装好了。


如果出现如下文本:

Searching for binary rubies, this might take some time.

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

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)


上述原因是未 安装 Homebrew 

参考博客 http://www.cnblogs.com/lzrabbit/p/4032515.html

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


安装好以后  再次执行<installation successful说明Homebrew安装好了> 

$ rvm install 2.0.0


Searching for binary rubies, this might take some time.

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

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

Checking requirements for osx.

Installing requirements for osx.

Updating system.....

Installing required packages: readline, libksba, openssl......

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

Requirements installation successful.

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

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

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

                                 Dload  Upload   Total   Spent    Left  Speed

 13 10.2M   13 1382k    0     0   9019      0  0:19:55  0:02:36  0:17:19  3





        另附:

       查询已经安装的ruby

   $ rvm list

        卸载一个已安装版本 

      $ rvm remove 1.9.2

 步骤3 - 设置 Ruby 版本


          RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本

    $ rvm 2.0.0 --default

          同样,也可以用其他版本号,前提是你有用 rvm install 安装过那个版本

          这个时候你可以测试是否正确

    $ ruby -v

    

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]


    $ gem -v

    2.1.6


        这有可能是因为Ruby的默认源使用的是cocoapods.org,国内访问这个网址有时候会有问题,网上的一种解决方案是将远替换成淘宝的,替换方式如下:

     $gem source -r https://rubygems.org/

https://rubygems.org/ removed from sources


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

https://ruby.taobao.org added to sources


 要想验证是否替换成功了,可以执行:

    gem sources -l  

*** CURRENT SOURCES ***


正常的输出结果:

      CURRENT SOURCES            

      http://ruby.taobao.org/            

到这里就已经把Ruby环境成功的安装到了Mac OS X上,接下来就可以进行相应的开发使用了。

    步骤4 - 安装cocoapods

     $ sudo gem install cocoapods

可能需要输入密码

Password:

Fetching: nap-1.1.0.gem (100%)

Successfully installed nap-1.1.0

Fetching: fourflusher-0.3.1.gem (100%)

Successfully installed fourflusher-0.3.1

Fetching: escape-0.0.4.gem (100%)

Successfully installed escape-0.0.4

Fetching: colored-1.2.gem (100%)

Successfully installed colored-1.2

Fetching: thread_safe-0.3.5.gem (100%)

Successfully installed thread_safe-0.3.5

Fetching: minitest-5.9.0.gem (100%)

Successfully installed minitest-5.9.0

Fetching: tzinfo-1.2.2.gem (100%)

Successfully installed tzinfo-1.2.2

Fetching: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: activesupport-4.2.6.gem (100%)

Successfully installed activesupport-4.2.6

Fetching: claide-1.0.0.gem (100%)

Successfully installed claide-1.0.0

Fetching: xcodeproj-1.1.0.gem (100%)

Successfully installed xcodeproj-1.1.0

Fetching: molinillo-0.4.5.gem (100%)

Successfully installed molinillo-0.4.5

Fetching: cocoapods-try-1.0.0.gem (100%)

Successfully installed cocoapods-try-1.0.0

Fetching: netrc-0.7.8.gem (100%)

Successfully installed netrc-0.7.8

Fetching: cocoapods-trunk-1.0.0.gem (100%)

Successfully installed cocoapods-trunk-1.0.0

Fetching: cocoapods-stats-1.0.0.gem (100%)

Successfully installed cocoapods-stats-1.0.0

Fetching: cocoapods-search-1.0.0.gem (100%)

Successfully installed cocoapods-search-1.0.0

Fetching: cocoapods-plugins-1.0.0.gem (100%)

Successfully installed cocoapods-plugins-1.0.0

Fetching: cocoapods-downloader-1.0.0.gem (100%)

Successfully installed cocoapods-downloader-1.0.0

Fetching: cocoapods-deintegrate-1.0.0.gem (100%)

Successfully installed cocoapods-deintegrate-1.0.0

Fetching: fuzzy_match-2.0.4.gem (100%)

Successfully installed fuzzy_match-2.0.4

Fetching: cocoapods-core-1.0.1.gem (100%)

Successfully installed cocoapods-core-1.0.1

Fetching: cocoapods-1.0.1.gem (100%)

Successfully installed cocoapods-1.0.1

Parsing documentation for nap-1.1.0

Installing ri documentation for nap-1.1.0

Parsing documentation for fourflusher-0.3.1

Installing ri documentation for fourflusher-0.3.1

Parsing documentation for escape-0.0.4

Installing ri documentation for escape-0.0.4

Parsing documentation for colored-1.2

Installing ri documentation for colored-1.2

Parsing documentation for thread_safe-0.3.5

Installing ri documentation for thread_safe-0.3.5

Parsing documentation for minitest-5.9.0

Installing ri documentation for minitest-5.9.0

Parsing documentation for tzinfo-1.2.2

Installing ri documentation for tzinfo-1.2.2

Parsing documentation for i18n-0.7.0

Installing ri documentation for i18n-0.7.0

Parsing documentation for activesupport-4.2.6

unable to convert "\x84" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping

Installing ri documentation for activesupport-4.2.6

Parsing documentation for claide-1.0.0

Installing ri documentation for claide-1.0.0

Parsing documentation for xcodeproj-1.1.0

Installing ri documentation for xcodeproj-1.1.0

Parsing documentation for molinillo-0.4.5

Installing ri documentation for molinillo-0.4.5

Parsing documentation for cocoapods-try-1.0.0

Installing ri documentation for cocoapods-try-1.0.0

Parsing documentation for netrc-0.7.8

Installing ri documentation for netrc-0.7.8

Parsing documentation for cocoapods-trunk-1.0.0

Installing ri documentation for cocoapods-trunk-1.0.0

Parsing documentation for cocoapods-stats-1.0.0

Installing ri documentation for cocoapods-stats-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-downloader-1.0.0

Installing ri documentation for cocoapods-downloader-1.0.0

Parsing documentation for cocoapods-deintegrate-1.0.0

Installing ri documentation for cocoapods-deintegrate-1.0.0

Parsing documentation for fuzzy_match-2.0.4

Installing ri documentation for fuzzy_match-2.0.4

Parsing documentation for cocoapods-core-1.0.1

Installing ri documentation for cocoapods-core-1.0.1

Parsing documentation for cocoapods-1.0.1

Installing ri documentation for cocoapods-1.0.1

23 gems installed

      等上十几秒钟,CocoaPods就可以在你本地下载并且安装好了,不再需要其他设置。

    4.10.11以上,上面的命令是不生效了,因为10.11把cocoapods直接干掉了

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

   

Successfully installed cocoapods-1.0.1

Parsing documentation for cocoapods-1.0.1

1 gem installed

 再加一句,完美解决

  $ sudo xcode-select --switch /Applications/Xcode.app

    在终端中输入如下命令来完成安装:(等待的时间不是一般的长啊,很长啊,大概有100M多点)


  $ pod setup

    如果安装失败,执行下面的:

etting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
mjqdeMacBook-Pro:~ jq$ pod repo remove master
[!] repo master does not exist
Usage:
    $ pod repo removeNAME
      Deletes the remote named `NAME` from the local spec-repos directory at
      `~/.cocoapods/repos/.`
Options:
    --silent    Show nothing
    --verbose   Show more debugging information
    --no-ansi   Show output without ANSI codes
    --help      Show help banner of specified command

附加信息:

Last login: Tue Nov 29 09:52:06 on ttys000

administrator:~ administrator$ $gem update --system

-bash: update: command not found

administrator:~ administrator$ gem update --system

Updating rubygems-update

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

Successfully installed rubygems-update-2.6.7

Parsing documentation for rubygems-update-2.6.7

Installing ri documentation for rubygems-update-2.6.7

Installing darkfish documentation for rubygems-update-2.6.7

Parsing documentation for rubygems-update-2.6.7

ERROR:  While executing gem ... (Errno::ENOENT)

    No such file or directory - /Users/administrator/.rvm/gems/ruby-2.0.0-p648/gems/rubygems-update-2.6.3

administrator:~ administrator$ sudo gem update —system

Password:

Sorry, try again.

Password:

Updating installed gems

Nothing to update

administrator:~ administrator$ gem -v

2.6.3

administrator:~ administrator$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

https://gems.ruby-china.org/ added to sources

source https://rubygems.org/ not present in cache

administrator:~ administrator$ gem sources -l

*** CURRENT SOURCES ***


https://ruby.taobao.org/

https://gems.ruby-china.org/

administrator:~ administrator$ gem sources --remove https://ruby.taobao.org/

https://ruby.taobao.org/ removed from sources

administrator:~ administrator$ gem sources -l

*** CURRENT SOURCES ***


https://gems.ruby-china.org/

administrator:~ administrator$ gem sources -a http://rubygems-china.oss.aliyuncs.com

http://rubygems-china.oss.aliyuncs.com added to sources

administrator:~ administrator$ sudo gem install cocoapods

Password:

Fetching: nanaimo-0.2.2.gem (100%)

Successfully installed nanaimo-0.2.2

Fetching: claide-1.0.1.gem (100%)

Successfully installed claide-1.0.1

Fetching: CFPropertyList-2.3.4.gem (100%)

Successfully installed CFPropertyList-2.3.4

Fetching: xcodeproj-1.4.1.gem (100%)

Successfully installed xcodeproj-1.4.1

Fetching: molinillo-0.5.4.gem (100%)

Successfully installed molinillo-0.5.4

Fetching: gh_inspector-1.0.2.gem (100%)

Successfully installed gh_inspector-1.0.2

Fetching: fourflusher-2.0.1.gem (100%)

Successfully installed fourflusher-2.0.1

Fetching: cocoapods-try-1.1.0.gem (100%)

Successfully installed cocoapods-try-1.1.0

Fetching: cocoapods-trunk-1.1.1.gem (100%)

Successfully installed cocoapods-trunk-1.1.1

Fetching: cocoapods-stats-1.0.0.gem (100%)

Successfully installed cocoapods-stats-1.0.0

Fetching: cocoapods-search-1.0.0.gem (100%)

Successfully installed cocoapods-search-1.0.0

Fetching: cocoapods-plugins-1.0.0.gem (100%)

Successfully installed cocoapods-plugins-1.0.0

Fetching: cocoapods-downloader-1.1.2.gem (100%)

Successfully installed cocoapods-downloader-1.1.2

Fetching: cocoapods-deintegrate-1.0.1.gem (100%)

Successfully installed cocoapods-deintegrate-1.0.1

Fetching: cocoapods-core-1.1.1.gem (100%)

Successfully installed cocoapods-core-1.1.1

Fetching: cocoapods-1.1.1.gem (100%)

Successfully installed cocoapods-1.1.1

Parsing documentation for nanaimo-0.2.2

Installing ri documentation for nanaimo-0.2.2

Parsing documentation for claide-1.0.1

Installing ri documentation for claide-1.0.1

Parsing documentation for CFPropertyList-2.3.4

Installing ri documentation for CFPropertyList-2.3.4

Parsing documentation for xcodeproj-1.4.1

Installing ri documentation for xcodeproj-1.4.1

Parsing documentation for molinillo-0.5.4

Installing ri documentation for molinillo-0.5.4

Parsing documentation for gh_inspector-1.0.2

Installing ri documentation for gh_inspector-1.0.2

Parsing documentation for fourflusher-2.0.1

Installing ri documentation for fourflusher-2.0.1

Parsing documentation for cocoapods-try-1.1.0

Installing ri documentation for cocoapods-try-1.1.0

Parsing documentation for cocoapods-trunk-1.1.1

Installing ri documentation for cocoapods-trunk-1.1.1

Parsing documentation for cocoapods-stats-1.0.0

Installing ri documentation for cocoapods-stats-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-downloader-1.1.2

Installing ri documentation for cocoapods-downloader-1.1.2

Parsing documentation for cocoapods-deintegrate-1.0.1

Installing ri documentation for cocoapods-deintegrate-1.0.1

Parsing documentation for cocoapods-core-1.1.1

Installing ri documentation for cocoapods-core-1.1.1

Parsing documentation for cocoapods-1.1.1

Installing ri documentation for cocoapods-1.1.1

16 gems installed

administrator:~ administrator$ 






  $ pod repo remove master  

  $ pod setup

0 0
原创粉丝点击