cocoapods的安装

《一》安装ruby   安装cocoapods先要安装ruby环境

 对于新入门的开发者,如何安装 Ruby和Ruby Gems 的运行环境可能会是个问题,本页主要介绍如何用一条靠谱的路子快速安装 Ruby 开发环境。
此安装方法同样适用于产品环境!

系统需求

首先确定操作系统环境,不建议在 Windows 上面搞,所以你需要用:

  • Mac OS X 
  • 任意 Linux 发行版本(Ubuntu,CentOS, Redhat, ArchLinux ...)

强烈新手使用 Ubuntu 省掉不必要的麻烦!

以下代码区域,带有 $ 打头的表示需要在控制台(终端)下面执行(不包括 $ 符号)

步骤0 - 安装系统需要的包

 

  # For Mac 
  # 先安装 [Xcode](http://developer.apple.com/xcode/) 开发工具,它将帮你安装好 Unix 环境需要的开发包

步骤1 - 安装 RVM

 

RVM 是干什么的这里就不解释了,后面你将会慢慢搞明白。

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

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

然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)

    $ source ~/.rvm/scripts/rvm

检查一下是否安装正确

    $ rvm -v
    rvm 1.22.17 (stable) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]

步骤2 - 用 RVM 安装 Ruby 环境

  

列出已知的ruby版本

   $ rvm list known

 

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

 

    $ rvm install 2.0.0

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

另附:

查询已经安装的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/     $ gem source -a https://ruby.taobao.org

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

    $ gem sources -l  

正常的输出结果:

      CURRENT SOURCES            

      http://ruby.taobao.org/            

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

《二》 安装Cocoapods

gem是一个管理ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/)源来查找、安装、升级和卸载软件包

但由于其外国网站,贼慢,故将其移除,添加使用淘宝的网站

一、换掉源头

1.安装:sudo gem install cocoapods  终止命令 ctrl + c

2.移除当前源:gem source --remove https://rubygems.org/  显示https://rubygems.org/ removed from sources即移除成功

3.添加淘宝源:gem source -a https://ruby.taobao.org/  添加gem source -a http://ruby.taobao.org/ 404 后添加gem source -a https://ruby.taobao.org/ 即可 添加成功显示:https://ruby.taobao.org/ added to sources

4.查看源是否安装成功:gem sources -l  显示:*** CURRENT SOURCES ***

https://ruby.taobao.org/

二、升级gem为最新版本

  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

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


Bug fixes:


* Sort installed versions to make sure we install the latest version when

  running `gem update --system`. As a one-time fix, run

  `gem update --system=2.6.6`. Pull request #1601 by David Radcliffe.


=== 2.6.5 / 2016-06-21


Minor enhancements:


* Support for unified Integer in Ruby 2.4. Pull request #1618

  by SHIBATA Hiroshi.

* Update vendored Molinillo to 0.5.0 for performance improvements.

  Pull request #1638 by Samuel Giddins.


Bug fixes:


* Raise an explicit error if Signer#sign is called with no certs. Pull

  request #1605 by Daniel Berger.

* Update `update_bundled_ca_certificates` utility script for directory

  nesting. Pull request #1583 by James Wen.

* Fix broken symlink support in tar writer (+ fix broken test). Pull

  request #1578 by Cezary Baginski.

* Remove extension directory before (re-)installing. Pull request #1576

  by Jeremy Hinegardner.

* Regenerate test CA certificates with appropriate extensions. Pull

  request #1611 by rhenium.

* Rubygems does not terminate on failed file lock when not superuser. Pull

  request #1582 by Ellen Marie Dash.

* Fix tar headers with a 101 character name. Pull request #1612 by Paweł

  Tomulik.

* Add Gem.platform_defaults to allow implementations to override defaults.

  Pull request #1644 by Charles Oliver Nutter.

* Run Bundler tests on TravisCI. Pull request #1650 by Samuel Giddins.


=== 2.6.4 / 2016-04-26


Minor enhancements:


* Use Gem::Util::NULL_DEVICE instead of hard coded strings. Pull request #1588

  by Chris Charabaruk.

* Use File.symlink on MS Windows if supported. Pull request #1418

  by Nobuyoshi Nakada.


Bug fixes:


* Redact uri password from error output when gem fetch fails. Pull request

  #1565 by Brian Fletcher.

* Suppress warnings. Pull request #1594 by Nobuyoshi Nakada.

* Escape user-supplied content served on web pages by `gem server` to avoid

  potential XSS vulnerabilities. Samuel Giddins.


=== 2.6.3 / 2016-04-05


Minor enhancements:


* Lazily calculate Gem::LoadError exception messages. Pull request #1550

  by Aaron Patterson.

* New fastly cert. Pull request #1548 by David Radcliffe.

* Organize and cleanup SSL certs. Pull request #1555 by James Wen.

* [RubyGems] Make deprecation message for paths= more helpful. Pull

  request #1562 by Samuel Giddins.

* Show default gems when using "gem list". Pull request #1570 by Luis

  Sagastume.


Bug fixes:


* Stub ordering should be consistent regardless of how cache is populated.

  Pull request #1552 by Aaron Patterson.

* Handle cases when the @@stubs variable contains non-stubs. Pull request

  #1558 by Per Lundberg.

* Fix test on Windows for inconsistent temp path. Pull request #1554 by

  Hiroshi Shirosaki.

* Fix `Gem.find_spec_for_exe` picks oldest gem. Pull request #1566 by

  Shinichi Maeshima.

* [Owner] Fallback to email and userid when owner email is missing. Pull

  request #1569 by Samuel Giddins.

* [Installer] Handle nil existing executable. Pull request #1561 by Samuel

  Giddins.

* Allow two digit version numbers in the tests. Pull request #1575 by unak.


=== 2.6.2 / 2016-03-12


Bug fixes:


* Fix wrong version of gem activation for bin stub. Pull request #1527 by

  Aaron Patterson.

* Speed up gem activation failures. Pull request #1539 by Aaron Patterson.

* Fix platform sorting in the resolver. Pull request #1542 by Samuel E.

  Giddins.

* Ensure we unlock the monitor even if try_activate throws. Pull request

  #1538 by Charles Oliver Nutter.



=== 2.6.1 / 2016-02-28


Bug fixes:


* Ensure `default_path` and `home` are set for paths. Pull request #1513

  by Aaron Patterson.

* Restore but deprecate support for Array values on `Gem.paths=`. Pull

  request #1514 by Aaron Patterson.

* Fix invalid gem file preventing gem install from working. Pull request

  #1499 by Luis Sagastume.


=== 2.6.0 / 2016-02-26


Minor enhancements:


* RubyGems now defaults the `gem push` to the gem's "allowed_push_host"

  metadata setting.  Pull request #1486 by Josh Lane.

* Update bundled Molinillo to 0.4.3. Pull request #1493 by Samuel E. Giddins.

* Add version option to gem open command. Pull request #1483 by Hrvoje

  Šimić.

* Feature/add silent flag. Pull request #1455 by Luis Sagastume.

* Allow specifying gem requirements via env variables. Pull request #1472

  by Samuel E. Giddins.


Bug fixes:


* RubyGems now stores `gem push` credentials under the host you signed-in for.

  Pull request #1485 by Josh Lane.

* Move `coding` location to first line. Pull request #1471 by SHIBATA

  Hiroshi.

* [PathSupport] Handle a regexp path separator. Pull request #1469 by

  Samuel E. Giddins.

* Clean up the PathSupport object. Pull request #1094 by Aaron Patterson.

* Join with File::PATH_SEPARATOR in Gem.use_paths. Pull request #1476 by

  Samuel E. Giddins.

* Handle when the gem home and gem path arent set in the config file. Pull

  request #1478 by Samuel E. Giddins.

* Terminate TimeoutHandler. Pull request #1479 by Nobuyoshi Nakada.

* Remove redundant cache. Pull request #1482 by Eileen M. Uchitelle.

* Freeze `Gem::Version@segments` instance variable. Pull request #1487 by

  Ben Dean.

* Gem cleanup is trying to uninstall gems outside GEM_HOME and reporting

  an error after it tries. Pull request #1353 by Luis Sagastume.

* Avoid duplicated sources. Pull request #1489 by Luis Sagastume.

* Better description for quiet flag. Pull request #1491 by Luis Sagastume.

* Raise error if find_by_name returns with nil. Pull request #1494 by

  Zoltán Hegedüs.

* Find_files only from loaded_gems when using gemdeps. Pull request #1277

  by Michal Papis.



------------------------------------------------------------------------------


RubyGems installed the following executables:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem


Ruby Interactive (ri) documentation was installed. ri is kind of like man 

pages for ruby libraries. You may access it like this:

  ri Classname

  ri Classname.class_method

  ri Classname#instance_method

If you do not wish to install this documentation in the future, use the

--no-document flag, or set it as the default in your ~/.gemrc file. See

'gem help env' for details.


RubyGems system software updated

localhost:~ yanghuan$ clesr

-bash: clesr: command not found

localhost:~ yanghuan$ clesr

-bash: clesr: command not found

localhost:~ yanghuan$ 


三、安装cocoa pods

命令:sudo gem install cocoapods

报错,安装时:ERROR:  Error installing cocoapods:

activesupport requires Ruby version >= 2.2.2.(原因ruby版本太低)

命令查看ruby的版本:ruby -v  

ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]


( 一 )升级ruby版本

1、安装RVM:Ruby版本管理器,包括Ruby版本管理和Gem库管理


1.1安装RVM命令:curl -L get.rvm.io | bash -s stable


localhost:~ yanghuan$ curl -L get.rvm.io | bash -s stable

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

                                 Dload  Upload   Total   Spent    Left  Speed

100   184  100   184    0     0    140      0  0:00:01  0:00:01 --:--:--   140

100 22865  100 22865    0     0   5329      0  0:00:04  0:00:04 --:--:--  9321

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

curl: (35) Server aborted the SSL handshake


Could not download 'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc'.

  curl returned status '35'.



Installing RVM to /Users/yanghuan/.rvm/

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

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

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


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

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


# yanghuan,

#

#   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/help and https://twitter.com/rvm_io

localhost:~ yanghuan$ 


1.2 、

命令:source ~/.bashrc (暂不知何用)

1.3

命令:source ~/.bash_profile (暂不知何用)

1.4、

命令:rvm -v (查看ram版本,即查看rvm是否安装成功)

显示:rvm 1.27.0 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

localhost:~ yanghuan$ 


2、用rvm升级ruby

2.1 命令 查看当前版本的ruby:ruby -v 显示:ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]

2.2命令 列出已知版本的rubyrvm 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- --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

localhost:~ yanghuan$ 


2.2命令 安装ruby2.3:rvm install 2.3 接下来就是根据提示按了几下回车。。。。漫长等待中。。。。

显示:

Searching for binary rubies, this might take some time.

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

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)

: 

==> 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:

/usr/local/.

/usr/local/bin

==> The following directories will have their owner set to yanghuan:

/usr/local/.

/usr/local/bin

==> The following directories will have their group set to admin:

/usr/local/.

/usr/local/bin


Press RETURN to continue or any other key to abort

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin

Password:

==> /usr/bin/sudo /usr/sbin/chown yanghuan /usr/local/. /usr/local/bin

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin

==> /usr/bin/sudo /bin/mkdir -p /Users/yanghuan/Library/Caches/Homebrew

==> /usr/bin/sudo /bin/chmod g+rwx /Users/yanghuan/Library/Caches/Homebrew

==> /usr/bin/sudo /usr/sbin/chown yanghuan /Users/yanghuan/Library/Caches/Homebrew

==> Downloading and installing Homebrew...

remote: Counting objects: 532, done.

remote: Compressing objects: 100% (473/473), done.

remote: Total 532 (delta 32), reused 340 (delta 28), pack-reused 0

Receiving objects: 100% (532/532), 812.26 KiB | 27.00 KiB/s, done.

Resolving deltas: 100% (32/32), done.

From https://github.com/Homebrew/brew

 * [new branch]      master     -> origin/master

HEAD is now at 06fe347 os/mac/ruby_keg: improve error reporting

==> Tapping homebrew/core

Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...

remote: Counting objects: 3720, done.

remote: Compressing objects: 100% (3607/3607), done.

remote: Total 3720 (delta 15), reused 1856 (delta 4), pack-reused 0

Receiving objects: 100% (3720/3720), 2.88 MiB | 4.00 KiB/s, done.

Resolving deltas: 100% (15/15), done.

Checking connectivity... done.

Tapped 3598 formulae (3,746 files, 9.0M)

==> Installation successful!

==> Next steps

Run `brew help` to get started

Further documentation: https://git.io/brew-docs

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

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

Requirements installation successful.

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

ruby-2.3.0 - #downloading ruby-2.3.0, 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 13.5M  100 13.5M    0     0  64816      0  0:03:38  0:03:38 --:--:-- 74349

ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/yanghuan/.rvm/src/ruby-2.3.0....

ruby-2.3.0 - #configuring...........................................................

ruby-2.3.0 - #post-configuration.

ruby-2.3.0 - #compiling.............................................................

ruby-2.3.0 - #installing.........

ruby-2.3.0 - #making binaries executable..

Installed rubygems 2.5.1 is newer than 2.4.8 provided with installed ruby, skipping installation, use --force to force installation.

ruby-2.3.0 - #gemset created /Users/yanghuan/.rvm/gems/ruby-2.3.0@global

ruby-2.3.0 - #importing gemset /Users/yanghuan/.rvm/gemsets/global.gems...........................................|

ruby-2.3.0 - #generating global wrappers........

ruby-2.3.0 - #gemset created /Users/yanghuan/.rvm/gems/ruby-2.3.0

ruby-2.3.0 - #importing gemsetfile /Users/yanghuan/.rvm/gemsets/default.gems evaluated to empty gem list

ruby-2.3.0 - #generating default wrappers........

ruby-2.3.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).

Install of ruby-2.3.0 - #complete 

Ruby was built without documentation, to build it run: rvm docs generate-ri


2.3命令 查看ruby版本 ruby -v 显示:ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]


(二 )安装cocoapods

 1.1 命令 安装cocoa pods:sudo gem install cocoapods

   显示:

Fetching: i18n-0.7.0.gem (100%)

Successfully installed i18n-0.7.0

Fetching: thread_safe-0.3.5.gem (100%)

Successfully installed thread_safe-0.3.5

Fetching: tzinfo-1.2.2.gem (100%)

Successfully installed tzinfo-1.2.2

Fetching: concurrent-ruby-1.0.2.gem (100%)

Successfully installed concurrent-ruby-1.0.2

Fetching: activesupport-5.0.0.gem (100%)

Successfully installed activesupport-5.0.0

Fetching: nap-1.1.0.gem (100%)

Successfully installed nap-1.1.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: claide-1.0.0.gem (100%)

Successfully installed claide-1.0.0

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

Successfully installed cocoapods-deintegrate-1.0.0

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

Successfully installed cocoapods-downloader-1.1.0

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

Successfully installed cocoapods-plugins-1.0.0

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

Successfully installed cocoapods-search-1.0.0

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

Successfully installed cocoapods-stats-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-try-1.1.0.gem (100%)

Successfully installed cocoapods-try-1.1.0

Fetching: molinillo-0.4.5.gem (100%)

Successfully installed molinillo-0.4.5

Fetching: colored-1.2.gem (100%)

Successfully installed colored-1.2

Fetching: xcodeproj-1.2.0.gem (100%)

Successfully installed xcodeproj-1.2.0

Fetching: escape-0.0.4.gem (100%)

Successfully installed escape-0.0.4

Fetching: fourflusher-0.3.2.gem (100%)

Successfully installed fourflusher-0.3.2

Fetching: cocoapods-1.0.1.gem (100%)

Successfully installed cocoapods-1.0.1

Parsing documentation for i18n-0.7.0

Installing ri documentation for i18n-0.7.0

Parsing documentation for thread_safe-0.3.5

Installing ri documentation for thread_safe-0.3.5

Parsing documentation for tzinfo-1.2.2

Installing ri documentation for tzinfo-1.2.2

Parsing documentation for concurrent-ruby-1.0.2

Installing ri documentation for concurrent-ruby-1.0.2

Parsing documentation for activesupport-5.0.0

Installing ri documentation for activesupport-5.0.0

Parsing documentation for nap-1.1.0

Installing ri documentation for nap-1.1.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 claide-1.0.0

Installing ri documentation for claide-1.0.0

Parsing documentation for cocoapods-deintegrate-1.0.0

Installing ri documentation for cocoapods-deintegrate-1.0.0

Parsing documentation for cocoapods-downloader-1.1.0

Installing ri documentation for cocoapods-downloader-1.1.0

Parsing documentation for cocoapods-plugins-1.0.0

Installing ri documentation for cocoapods-plugins-1.0.0

Parsing documentation for cocoapods-search-1.0.0

Installing ri documentation for cocoapods-search-1.0.0

Parsing documentation for cocoapods-stats-1.0.0

Installing ri documentation for cocoapods-stats-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-try-1.1.0

Installing ri documentation for cocoapods-try-1.1.0

Parsing documentation for molinillo-0.4.5

Installing ri documentation for molinillo-0.4.5

Parsing documentation for colored-1.2

Installing ri documentation for colored-1.2

Parsing documentation for xcodeproj-1.2.0

Installing ri documentation for xcodeproj-1.2.0

Parsing documentation for escape-0.0.4

Installing ri documentation for escape-0.0.4

Parsing documentation for fourflusher-0.3.2

Installing ri documentation for fourflusher-0.3.2

Parsing documentation for cocoapods-1.0.1

Installing ri documentation for cocoapods-1.0.1

Done installing documentation for i18n, thread_safe, tzinfo, concurrent-ruby, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, colored, xcodeproj, escape, fourflusher, cocoapods after 19 seconds

23 gems installed


四、

1.初始化cocoapods(cocoapods安装后需要初始化,初始化的目的是将网络上的第三方框架的信息下载到本机上)

 命令初始化cocoapodspod setup

 显示:Setting up CocoaPods master repo      更新仓库repo,访问国外的网站太慢,故更换仓库

 ctrl + c 终止上述命令

2.命名 删除repo镜像国外服务器:pod repo remove master

   显示:

     [!] repo master does not exist


Usage:


    $ pod repo remove NAME


      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


3.命令 更换repo镜像为国内服务器:pod repo add master https://git.coding.net/akuandev/Specs.git (俺没用) 或者 pod repo add master  http://git.oschina.net/akuandev/Specs.git 

localhost:~ yanghuan$ pod repo add master https://git.coding.net/akuandev/Specs.git

[!] To setup the master specs repo, please run `pod setup`.

  

4.命令 更新第三方库:pod repo update(非第一次更新cocoapods)

   命令 更新第三方库:pod setup(第一次更新cocoapods)


创建并可以编辑Podfile的命令:vim Podfile ;输入 i,进入Podfile的编辑状态,可以向Podfile中添加第三方库;结束编辑点击键盘上的esc按钮,输入“:wq”即可保存并退出编辑;在非i状态下输入dd命令,删除当前行;

回到根目录命名:open ./  

查看Podfile文件的内容:cat Podfile


5.创建一个工程

6.通过终端进入到此工程目录下

7.创建Podfile文件

vim Podfile   创建Podfile文件 (此种创建方式有问题) pod init 才是正确的

platform :ios, '8.0'   工程对应的iOS版本

pod ‘SDWebImage’   添加第三方库(默认最新版本)

pod ‘Masonry’ ,’~>2.0’   添加第三方库 (指定2.0版本的)

esc -》:-》wq退出Podfile文件的编辑

open ./   进入当前文件夹

cat Podfile 查看Podfile文件的详细内容,能显示加入到Podfile文件的所有第三方库

pod install  从当前文件夹下找Podfile内的第三方并安装

//安装Masonry

添加某个都三方库的详细设置:

platform空格:iOS, ‘8.0’

pod ‘Masonry’(不分安装的版本)  pod ‘Masonry’,‘~>0.0.2(安装0.0.2版本的Masonry)


pod search ‘Masonry’,‘~>0.0.2’


pod install 命令:在当前工程的文件目录下,执行此命令,从当前文件查找Podfile文件,并安装第三方框架

```


### Report


* What did you do?


* What did you expect to happen?


* What happened instead?



### Stack


```

   CocoaPods : 1.0.1

        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

    RubyGems : 2.6.6

        Host : Mac OS X 10.11.3 (15D21)

       Xcode : 7.3 (7D175)

         Git : git version 2.6.4 (Apple Git-63)

Ruby lib dir : /Users/yanghuan/.rvm/rubies/ruby-2.3.0/lib

Repositories : master - https://github.com/CocoaPods/Specs.git @ 327fd44f1a9f37642547eb32ac8b6cf32b30f58b

```


### Plugins


```

cocoapods-deintegrate : 1.0.0

cocoapods-plugins     : 1.0.0

cocoapods-search      : 1.0.0

cocoapods-stats       : 1.0.0

cocoapods-trunk       : 1.0.0

cocoapods-try         : 1.1.0

```


### Podfile


```ruby

platform :ios, '8.0'

pod 'SDWebImage'

pod 'Masonry', '~2.0'

```


### Error


```

ArgumentError - Illformed requirement `"~2.0"`

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:63:in `parse'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:88:in `block in initialize'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:88:in `map!'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:88:in `initialize'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:34:in `new'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/requirement.rb:34:in `create'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/dependency.rb:116:in `initialize'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:713:in `new'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:713:in `block in pod_dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:709:in `map'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:709:in `pod_dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:95:in `non_inherited_dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile/target_definition.rb:71:in `dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile.rb:91:in `map'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-core-1.0.1/lib/cocoapods-core/podfile.rb:91:in `dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/lib/cocoapods/installer/analyzer.rb:642:in `sources'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/lib/cocoapods/installer.rb:144:in `resolve_dependencies'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/lib/cocoapods/installer.rb:114:in `install!'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/lib/cocoapods/command/install.rb:37:in `run'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/lib/cocoapods/command.rb:50:in `run'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-1.0.1/bin/pod:55:in `'

/Users/yanghuan/.rvm/rubies/ruby-2.3.0/bin/pod:22:in `load'

/Users/yanghuan/.rvm/rubies/ruby-2.3.0/bin/pod:22:in `

'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/bin/ruby_executable_hooks:15:in `eval'

/Users/yanghuan/.rvm/gems/ruby-2.3.0@global/bin/ruby_executable_hooks:15:in `

'

```


――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――


[!] Oh no, an error occurred.


Search for existing GitHub issues similar to yours:

https://github.com/CocoaPods/CocoaPods/search?q=Illformed+requirement+%60%22%7E2.0%22%60&type=Issues


If none exists, create a ticket, with the template displayed above, on:

https://github.com/CocoaPods/CocoaPods/issues/new


Be sure to first read the contributing guide for details on how to properly submit a ticket:

https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md


Don't forget to anonymize any private data!

 

解决pod install出现的错误:

try1:sudo rm -fr ~/.cocoapods/repos/master  ==>  pod setup

pod --version 查看cocoa pods的版本号

为了安全起见,执行命令"sudogem uninstall cocoapods",卸载原有的CocoaPod







你可能感兴趣的:(移动)