史上最全CocoaPods安装和使用教程

一.正常安装过程

1.先检查ruby的版本

ruby -v

builderdeMac-mini:~ builder$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
builderdeMac-mini:~ builder$ 

截图如下:

史上最全CocoaPods安装和使用教程_第1张图片


2.替换为taobao源(后面发现不行,又换了其他的源,可在后面查看)

gem sources --remove https://rubygems.org/  移除

gem sources --a https://ruby.taobao.org/ 添加

gem sources - l  查看

builderdeMac-mini:~ builder$ gem sources --remove http://rubygems.org/
source http://rubygems.org/ not present in cache
builderdeMac-mini:~ builder$ gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
builderdeMac-mini:~ builder$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
builderdeMac-mini:~ builder$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/
截图如下:

史上最全CocoaPods安装和使用教程_第2张图片


3.安装cocoapods

sudo gem install cocoapods

builderdeMac-mini:~ builder$ sudo gem install cocoapods
Password:
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fourflusher-0.3.2.gem (100%)
Successfully installed fourflusher-0.3.2
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: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
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: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-5.0.0.1.gem (100%)
Successfully installed activesupport-5.0.0.1
Fetching: claide-1.0.0.gem (100%)
Successfully installed claide-1.0.0
Fetching: xcodeproj-1.3.0.gem (100%)
Successfully installed xcodeproj-1.3.0
Fetching: molinillo-0.4.5.gem (100%)
Successfully installed molinillo-0.4.5
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.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.1.1.gem (100%)
Successfully installed cocoapods-downloader-1.1.1
Fetching: cocoapods-deintegrate-1.0.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.1
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.2
Installing ri documentation for fourflusher-0.3.2
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 concurrent-ruby-1.0.2
Installing ri documentation for concurrent-ruby-1.0.2
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 i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for activesupport-5.0.0.1
Installing ri documentation for activesupport-5.0.0.1
Parsing documentation for claide-1.0.0
Installing ri documentation for claide-1.0.0
Parsing documentation for xcodeproj-1.3.0
Installing ri documentation for xcodeproj-1.3.0
Parsing documentation for molinillo-0.4.5
Installing ri documentation for molinillo-0.4.5
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.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.1.1
Installing ri documentation for cocoapods-downloader-1.1.1
Parsing documentation for cocoapods-deintegrate-1.0.1
Installing ri documentation for cocoapods-deintegrate-1.0.1
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
Done installing documentation for nap, fourflusher, escape, colored, concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, claide, xcodeproj, molinillo, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, cocoapods-core, cocoapods after 20 seconds
23 gems installed
builderdeMac-mini:~ builder$ 

出现上面的log说明安装成功了,否则出问题了。


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

二.安装过程出现问题解决


1.安装cocoapods遇到ruby版本过低问题:

builderdeMac-mini:~ builder$ sudo gem install cocoapods
Password:
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: minitest-5.9.0.gem (100%)
Successfully installed minitest-5.9.0
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.1.gem (100%)
ERROR:  Error installing cocoapods:
	activesupport requires Ruby version >= 2.2.2.
builderdeMac-mini:~ builder$ 
截图如下:
史上最全CocoaPods安装和使用教程_第3张图片


解决方案:

1).先安装rvm版本管理

curl -L get.rvm.io | bash -s stable

builderdeMac-mini:~ builder$ 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    309      0 --:--:-- --:--:-- --:--:--   308
100 22865  100 22865    0     0   6915      0  0:00:03  0:00:03 --:--:-- 11518
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/builder/.rvm/
    Adding rvm PATH line to /Users/builder/.profile /Users/builder/.mkshrc /Users/builder/.bashrc /Users/builder/.zshrc.
    Adding rvm loading line to /Users/builder/.profile /Users/builder/.bash_profile /Users/builder/.zlogin.
Installation of RVM in /Users/builder/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/builder/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# builder,
#
#   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
builderdeMac-mini:~ builder$ 

看到这句

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io
那么继续执行

builderdeMac-mini:~ builder$ source ~/.bashrc
builderdeMac-mini:~ builder$ source ~/.bash_profile

检查rvm是否安装成功

builderdeMac-mini:~ builder$ rvm -v
rvm 1.27.0 (latest) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]
builderdeMac-mini:~ builder$ 

整个过程截图如下:

史上最全CocoaPods安装和使用教程_第4张图片

2).通过rvm升级ruby

检查ruby现在的版本,以及查看可以升级的版本

ruby -v 检查版本

rvm list known 查看

builderdeMac-mini:~ builder$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
builderdeMac-mini:~ builder$ 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- --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

3).升级cocoapods 2.2.2版本

rvm install 2.2.2

builderdeMac-mini:~ builder$ rvm install 2.2.2
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.10/x86_64/ruby-2.2.2.tar.bz2
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/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/share
/usr/local/lib/pkgconfig
/usr/local/share/aclocal
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
==> The following existing directories will have their owner set to builder:
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/share
/usr/local/lib/pkgconfig
/usr/local/share/aclocal
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/share
/usr/local/lib/pkgconfig
/usr/local/share/aclocal
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/etc
/usr/local/opt
/usr/local/sbin
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/include /usr/local/lib /usr/local/share /usr/local/lib/pkgconfig /usr/local/share/aclocal /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5
Password:
==> /usr/bin/sudo /usr/sbin/chown builder /usr/local/bin /usr/local/include /usr/local/lib /usr/local/share /usr/local/lib/pkgconfig /usr/local/share/aclocal /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/include /usr/local/lib /usr/local/share /usr/local/lib/pkgconfig /usr/local/share/aclocal /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod u+rwx share/zsh share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown builder /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/mkdir -p /Users/builder/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/builder/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown builder /Users/builder/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 1038, done.
remote: Compressing objects: 100% (933/933), done.
remote: Total 1038 (delta 95), reused 591 (delta 68), pack-reused 0
Receiving objects: 100% (1038/1038), 1.05 MiB | 176.00 KiB/s, done.
Resolving deltas: 100% (95/95), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
HEAD is now at 066cd46 Merge pull request #1053 from sjackman/patch-1
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3725, done.
remote: Compressing objects: 100% (3617/3617), done.
remote: Total 3725 (delta 15), reused 1251 (delta 0), pack-reused 0
Receiving objects: 100% (3725/3725), 2.91 MiB | 239.00 KiB/s, done.
Resolving deltas: 100% (15/15), done.
Checking connectivity... done.
Tapped 3604 formulae (3,752 files, 9M)
Already up-to-date.
==> 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.
ruby-2.2.2 - #configure
ruby-2.2.2 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6854k  100 6854k    0     0  46977      0  0:02:29  0:02:29 --:--:--  118k
ruby-2.2.2 - #validate archive
ruby-2.2.2 - #extract
ruby-2.2.2 - #validate binary
ruby-2.2.2 - #setup
ruby-2.2.2 - #gemset created /Users/builder/.rvm/gems/ruby-2.2.2@global
ruby-2.2.2 - #importing gemset /Users/builder/.rvm/gemsets/global.gems..............................
ruby-2.2.2 - #generating global wrappers........
ruby-2.2.2 - #gemset created /Users/builder/.rvm/gems/ruby-2.2.2
ruby-2.2.2 - #importing gemsetfile /Users/builder/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.2 - #generating default wrappers........
Updating certificates in '/etc/openssl/cert.pem'.
mkdir: /etc/openssl: Permission denied
mkdir -p "/etc/openssl" failed, retrying with sudo
builder password required for 'mkdir -p /etc/openssl': 
and sudo mkdir worked
builderdeMac-mini:~ builder$ 
截图如下:
史上最全CocoaPods安装和使用教程_第5张图片


史上最全CocoaPods安装和使用教程_第6张图片

看到下面这些说明ruby已经升级成功

ruby-2.2.2 - #validate archive
ruby-2.2.2 - #extract
ruby-2.2.2 - #validate binary
ruby-2.2.2 - #setup
ruby-2.2.2 - #gemset created /Users/builder/.rvm/gems/ruby-2.2.2@global
ruby-2.2.2 - #importing gemset /Users/builder/.rvm/gemsets/global.gems..............................
ruby-2.2.2 - #generating global wrappers........
ruby-2.2.2 - #gemset created /Users/builder/.rvm/gems/ruby-2.2.2
ruby-2.2.2 - #importing gemsetfile /Users/builder/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.2 - #generating default wrappers........
Updating certificates in '/etc/openssl/cert.pem'.
mkdir: /etc/openssl: Permission denied
mkdir -p "/etc/openssl" failed, retrying with sudo
builder password required for 'mkdir -p /etc/openssl': 
and sudo mkdir worked


2.为防止gem版本过低,可先安装cocoapods前更新gem

sudo gem update --system

builderdeMac-mini:~ builder$ sudo gem update --system
Password:

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 25 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

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.

=== 2.5.2 / 2016-01-31

Bug fixes:

* Fix memoization of Gem::Version#prerelease? Pull request #1125 by Matijs van
  Zuijlen.
* Handle trailing colons in GEM_PATH, by Damien Robert.
* Improve the Gemfile `gemspec` method, fixing #1204 and #1033. Pull request
  #1276 by Michael Papis.
* Warn only once when a gemspec license is invalid. Pull request #1414 by Samuel
  E. Giddins.
* Check for exact constants before using them, fixing Ruby bug #11940. Pull
  request #1438 by Nobuyoshi Nakada.
* Fix building C extensions on Ruby 1.9.x on Windows. Pull request #1453 by Marie
  Markwell.
* Handle symlinks containing ".." correctly. Pull request #1457 by Samuel E.
  Giddins.

Minor enhancements:

* Add `--no-rc` flag, which skips loading `.gemrc`. Pull request #1329 by Luis
  Sagastume.
* Allow basic auth to be excluded from `allowed_push_host`. By Josh Lane.
* Add `gem list --exact`, which finds gems by string match instead of regex. Pull
  request #1344 by Luis Sagastume.
* Suggest alternatives when gem license is unknown. Pull request #1443 by Samuel
  E. Giddins.
* Print a useful error if a binstub expects a newer version of a gem than is
  installed. Pull request #1407 by Samuel E. Giddins.
* Allow the (supported) s3:// scheme to be used with `--source`. Pull request
  #1416 by Dave Adams.
* Add `--[no-]post-install-message` to `install` and `update`. Pull request #1162
  by Josef Šimánek.
* Add `--host` option to `yank`, providing symmetry with `pull`. Pull request
  #1361 by Mike Virata-Stone.
* Update bundled Molinillo to 0.4.1. Pull request #1452 by Samuel E. Giddins.
* Allow calling `build` without '.gemspec'. Pull request #1454 by Stephen
  Blackstone.
* Add support for `source` option on gems in Gemfile. Pull request #1355 by
  Michael Papis.
* Function correctly when string literals are frozen on Ruby 2.3. Pull request
  #1408 by Samuel E. Giddins.

=== 2.5.1 / 2015-12-10

Bug fixes:

* Ensure platform sorting only uses strings. Affected binary installs on Windows.
  Issue #1369 reported by Ryan Atball (among others).
  Pull request #1375 by Samuel E. Giddins.
* Revert PR #1332. Unable to reproduce, and nil should be impossible.
* Gem::Specification#to_fullpath now returns .rb extensions when such a file
  exists.  Pull request #1114 by y-yagi.
* RubyGems now handles Net::HTTPFatalError instead of crashing.  Pull
  request #1314 by Samuel E. Giddins.
* Updated bundled Molinillo to 0.4.0.  Pull request #1322, #1396 by Samuel E.
  Giddins.
* Improved performance of spec loading by reducing likelihood of loading the
  complete specification.  Pull request #1373 by Aaron Patterson.
* Improved caching of requirable files  Pull request #1377 by Aaron Patterson.
* Fixed activation of gems with development dependencies.  Pull request #1388
  by Samuel E. Giddins.
* RubyGems now uses the same Molinillo vendoring strategy as Bundler.  Pull
  request #1397 by Samuel E. Giddins.
* Fixed documentation of Gem::Requirement.parse.  Pull request #1398 by
  Juanito Fatas.
* RubyGems no longer warns when a prerelease gem has prerelease dependencies.
  Pull request #1399 by Samuel E. Giddins.
* Fixed Gem::Version documentation example.  Pull request #1401 by Guilherme
  Goettems Schneider.
* Updated documentation links to https://.  Pull request #1404 by Suriyaa
  Kudo.
* Fixed double word typo.  Pull request #1411 by Jake Worth.

=== 2.5.0 / 2015-11-03

Major enhancements:

* Added the Gem::Licenses class which provides a set of standard license
  identifiers as set by spdx.org. This is now used by the
  Gem::Specification#license attribute to try to standardize (though not
  enforce) licenses set by gem authors.

  Pull request #1249 by Kyle Mitchell.

Minor enhancements:

* Use Molinillo as the resolver library.  This is the same resolver as used by
  Bundler.  Pull request #1189 by Samuel E. Giddins.
* Add `--skip=gem_name` to Pristine command.  Pull request #1018 by windwiny.
* The parsed gem dependencies file is now available via Gem.gemdeps following
  Gem.use_gemdeps.  Pull request #1224 by Hsing-Hui Hsu, issue #1213 by
  Michal Papis.
* Moved description attribute to recommended for Gem::Specification.
  Pull request #1046 by Michal Papis
* Moved `Gem::Indexer#abbreviate` and `#sanitize` to `Gem::Specification`.
  Pull request #1145 by Arthur Nogueira Neves
* Cache Gem::Version segments for `#bump` and `#release`.
  Pull request #1131 by Matijs van Zuijlen
* Fix edge case in `levenshtein_distance` for comparing longer strings.
  Pull request #1173 by Richard Schneeman
* Remove duplication from List#to_a, improving from O(n^2) to O(n) time.
  Pull request #1200 by Marc Siegel.
* Gem::Specification.add_specs is deprecated and will be removed from version
  3.0 with no replacement.  To add specs, install the gem, then reset the
  cache.
* Gem::Specification.add_spec is deprecated and will be removed from version
  3.0 with no replacement.  To add specs, install the gem, then reset the
  cache.
* Gem::Specification.remove_spec is deprecated and will be removed from version
  3.0 with no replacement.  To remove specs, uninstall the gem, then reset the
  cache by calling Gem::Specification.reset.
* Call Array#compact before calling Array#uniq for minor speed improvement in
  the Gem::Specification#files method.
  Pull request #1253 by Marat Amerov.
* Use stringio instead of custom String classes.
  Pull request #1250 by Petr Skocik.
* Use URI#host instead of URI#hostname to retain backwards compatibility with
  Ruby 1.9.2 and earlier in util library.
  Pull request #1288 by Joe Rafaniello.
* Documentation update for gem sources.
  Pull request #1324 by Ilya Vassilevsky.
* Documentation update for required_ruby_version.
  Pull request #1321 by Matt Patterson.
* Documentation update for gem update.
  Pull request #1306 by Tim Blair.
* Emit a warning on SRV resolve failure.
  Pull request #1023 by Ivan Kuchin.
* Allow duplicate dependencies between runtime and development.
  Pull request #1032 by Murray Steele.
* The gem env command now shows the user installation directory.
  Pull request #1343 by Luis Sagastume.
* The Gem::Platform#=== method now treats a nil cpu arch the same as 'universal'.
  Pull request #1356 by Daniel Berger.
* Improved memory performance in Gem::Specification.traverse.  Pull request
  #1188 by Aaron Patterson.
* RubyGems packages now support symlinks.  Pull request #1209 by Samuel E.
  Giddins.
* RubyGems no longer outputs mkmf.log if it does not exist.  Pull request
  #1222 by Andrew Hooker.
* Added Bitrig platform.  Pull request #1233 by John C. Vernaleo.
* Improved error message for first-time RubyGems developers.  Pull request
  #1241 by André Arko
* Improved performance of Gem::Specification#load with cached specs.  Pull
  request #1297 by Samuel E. Giddins.
* Gem::RemoteFetcher allows users to set HTTP headers.  Pull request #1363 by
  Agis Anastasopoulos.

Bug fixes:

* Fixed Rake homepage url in example for Gem::Specification#homepage.
  Pull request #1171 by Arthur Nogueira Neves
* Don't crash if partially uninstalled gem can't be found.
  Pull request #1283 by Cezary Baginski.
* Test warning cleanup.
  Pull request #1298 by Samuel E. Giddins.
* Documentation fix for GemDependencyAPI.
  Pull request #1308 by Michael Papis.
* Fetcher now ignores ENOLCK errors in single threaded environments. This
  handles an issue with gem installation on NFS as best we can. Addresses
  issue #1176 by Ryan Moore.
  Pull request #1327 by Daniel Berger.
* Fix some path quoting issues in the test suite.
  Pull request #1328 by Gavin Miller.
* Fix NoMethodError in running ruby processes when gems are uninstalled.
  Pull request #1332 by Peter Drake.
* Fixed a potential NoMethodError for gem cleanup.
  Pull request #1333 by Peter Drake.
* Fixed gem help bug.
  Issue #1352 reported by bogem, pull request #1357 by Luis Sagastume.
* Remove temporary directories after tests finish.  Pull request #1181 by
  Nobuyoshi Nokada.
* Update links in RubyGems documentation.  Pull request #1185 by Darío Hereñú.
* Prerelease gem executables can now be run.  Pull request #1186 by Samuel E.
  Giddins.
* Updated RubyGems travis-ci ruby versions.  Pull request #1187 by Samuel E.
  Giddins.
* Fixed release date of RubyGems 2.4.6.  Pull request #1190 by Frieder
  Bluemle.
* Fixed bugs in gem activation.  Pull request #1202 by Miklós Fazekas.
* Fixed documentation for `gem list`.  Pull request #1228 by Godfrey Chan.
* Fixed #1200 history entry.  Pull request #1234 by Marc Siegel.
* Fixed synchronization issue when resetting the Gem::Specification gem list.
  Pull request #1239 by Samuel E. Giddins.
* Fixed running tests in parallel.  Pull request #1257 by SHIBATA Hiroshi.
* Fixed running tests with `--program-prefix` or `--program-suffix` for ruby.
  Pull request #1258 by Shane Gibbs.
* Fixed Gem::Specification#to_yaml.  Pull request #1262 by Hiroaki Izu.
* Fixed taintedness of Gem::Specification#raw_require_paths.  Pull request
  #1268 by Sam Ruby.
* Fixed sorting of platforms when installing gems.  Pull request #1271 by
  nonsequitur.
* Use `--no-document` over deprecated documentation options when installing
  dependencies on travis.  Pull request #1272 by takiy33.
* Improved support for IPv6 addresses in URIs.  Pull request #1275 by Joe
  Rafaniello.
* Spec validation no longer crashes if a file does not exist.  Pull request
  #1278 by Samuel E. Giddins.
* Gems can now be installed within `rescue`.  Pull request #1282 by Samuel E.
  Giddins.
* Increased Diffie-Hellman key size for tests for modern OpenSSL.  Pull
  request #1290 by Vít Ondruch.
* RubyGems handles invalid config files better.  Pull request #1367 by Agis
  Anastasopoulos.

=== 2.4.8 / 2015-06-08

Bug fixes:

* Tightened API endpoint checks for CVE-2015-3900


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

RubyGems installed the following executables:
	/Users/builder/.rvm/rubies/ruby-2.2.2/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
builderdeMac-mini:~ builder$ 
builderdeMac-mini:~ builder$ 

gem升级完成了。

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

三.使用cocospods前准备

cocoapods安装成功后,先pod setup

pod setup卡着不动问题

builderdeMac-mini:~ builder$ pod setup
Setting up CocoaPods master repo

淘宝的源不可用,用其他的,或者 新开一个终端窗口,输入"cd ~/.cocoapods/"命令行跳到cocoapods文件夹内,执行"du -sh *"查看正在下载的文件夹的大小,如果没有大小变化,说明这个源有问题,需替换。

builderdeMac-mini:~ builder$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/
builderdeMac-mini:~ builder$ gem sources -r https://ruby.taobao.org/
https://ruby.taobao.org/ removed from sources
builderdeMac-mini:~ builder$ gem sources -a https://gems.ruby-china.org/
https://gems.ruby-china.org/ added to sources
builderdeMac-mini:~ builder$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org/
builderdeMac-mini:~ builder$ 

1)、那是因为 淘宝的那个镜像(https://ruby.taobao.org/ )已经不可用了。所以我们现在用最新支持的ruby镜像(https://gems.ruby-china.org/)

  需要的命令行:

  $ gem sources -r https://rubygems.org/ (移除旧版本的镜像,如果你不知道你电脑上目前用的是什么镜像,可用  gem sources -l  来查看
  $ gem sources -a https://gems.ruby-china.org/ (增加可用的镜像)
  $ gem sources -l  (用来检查使用替换镜像位置成功)

2)、当pod setup 进入Setting up CocoaPods master repo 等待的时候表示正在下载了,此时你通过新开一个终端窗口,输入"cd ~/.cocoapods/"命令行跳到cocoapods文件夹内,执行"du -sh *"查看正在下载的文件夹的大小

builderdeMac-mini:~ builder$ cd ~/.cocoapods/
builderdeMac-mini:.cocoapods builder$ du -sh
3.7M	.
builderdeMac-mini:.cocoapods builder$ du -sh
4.3M	.
builderdeMac-mini:.cocoapods builder$ du -sh
4.5M	.
builderdeMac-mini:.cocoapods builder$ du -sh
4.8M	.
builderdeMac-mini:.cocoapods builder$ du -sh
8.6M	.
builderdeMac-mini:.cocoapods builder$ 
下载这些需要时间很长,几百m,网络差要耐心等待一下。

3)、当出现如下

[!] An error occurred while performing `git pull` on repo `master`.

[!] /usr/bin/git pull --ff-only

这个错误应该是说这个节点有问题。就又找资料,然后试试把cocoapods的节点删除,重新添加一个节点,或许就行,说干就干:

原因: Cocoapods的分支不支持当前最新的Xcode版本

解决办法: 删除master分支 重新建立新的分支

sudo rm -fr ~/.cocoapods/repos/master

然后再: pod setup

正确过程如下:

builderdeMac-mini:~ builder$ pod setup
Setting up CocoaPods master repo

CocoaPods 1.1.0.rc.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.rc.2

Setup completed
builderdeMac-mini:~ builder$ 


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

四.cocoapods使用过程

cd进入到项目目录

builderdeMac-mini:PodTest builder$ ls
PodTest		PodTest.xcodeproj
builderdeMac-mini:PodTest builder$ vi Podfile
enter后进入vim的编辑模式,按i回车进入insert输入以下信息,输完后按esc退出insert,按出“:”,输入wq保存修改退出
platform :ios, '7.0'
#use_frameworks!个别需要用到它,比如reactiveCocoa

target 'PodTest' do
  pod 'AFNetworking', '~> 2.6'
  pod 'MBProgressHUD', '~> 1.0.0'
end

如图:

史上最全CocoaPods安装和使用教程_第7张图片
这时候你会发现项目底下有了一个名叫Podfile的文稿


然后pod install

builderdeMac-mini:PodTest builder$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.3)
Installing MBProgressHUD (1.0.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `PodTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods
installed.
builderdeMac-mini:PodTest builder$ 


成功后项目目录底下会多出

PodTest.xcworkspace

Pods

如图:

史上最全CocoaPods安装和使用教程_第8张图片

这时候的项目入口变成了.xcworkspace文件,而不是.xcodeproj

打开项目使用刚配置的库,运行成功,至此cocoapods使用过程已完成。

截图如下:

史上最全CocoaPods安装和使用教程_第9张图片



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

参考链接:

http://blog.csdn.net/showhilllee/article/details/38398119/

http://www.360doc.com/content/16/0314/17/27253262_542162190.shtml

http://blog.csdn.net/zhaoen95/article/details/51995520

http://blog.csdn.net/appxcode/article/details/51755073




你可能感兴趣的:(ios)