macOS Sierra 10.12.1 (Xcode8.1) 安裝CocoaPods

history.png

近期由于公司電腦磁盤頻繁提示磁盤空間不足琉历,每次看到都是臨時刪除一些文件騰出空間桃移,但時間不長又會提示磁盤不足,又懶得對電腦文件一一整理歸納院刁,所以最后決定格式化磁盤,重新安裝系統(tǒng)粪狼,想到在線安裝由于網(wǎng)速比較慢且浪費時間于是提前下載好鏡像黎比,使用U盤安裝,考慮到怕耽誤工作進度鸳玩,于是將開發(fā)所必須用到的工具都一一提前下載好阅虫,想著待電腦重裝完系統(tǒng)之后便可以對其一一安裝,沒想到期間還是遇到了一些坑不跟,那就是最后準備運行代碼更新cocoapods更新依賴庫的時候出現(xiàn)了問題颓帝,最后導(dǎo)致花了差不多一中午的時間再折騰這個事情,特此記錄一下窝革。

問題原因:

由于macOS Sierra 10.12.1 自帶ruby版本(2.0.0)過低购城,導(dǎo)致安裝cocoapods的時候出了各種問題,由于我個人電腦和公司電腦都碰到這個問題虐译,所以下面將介紹兩種安裝ruby的方式:

解決方式:

  • rvm(Ruby Version Manager) 不僅可以用來安裝ruby瘪板,還可以對不同的ruby版本進行管理的工具。
  • rbenv (Ruby environment) 同樣提供了對ruby版本進行管理的功能漆诽,兩者都能實現(xiàn)對ruby的管理侮攀,就安裝ruby來看這兩款管理工具操作起來都很簡單,只需一些簡單的命令行即可完成對ruby的安裝與管理厢拭。

一兰英、rvm 安裝ruby

1. 查看當(dāng)前ruby版本:
MacdeMacBook-Pro:~ mac$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
2. 安裝rvm管理工具:
MacdeMacBook-Pro:~ mac$ curl -L https://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     99      0  0:00:01  0:00:01 --:--:--    99
100 22921  100 22921    0     0   3972      0  0:00:05  0:00:05 --:--:--  6052
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: (28) Connection timed out after 30005 milliseconds

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

Installing RVM to /Users/mac/.rvm/
    Adding rvm PATH line to /Users/mac/.profile /Users/mac/.mkshrc /Users/mac/.bashrc /Users/mac/.zshrc.
    Adding rvm loading line to /Users/mac/.profile /Users/mac/.bash_profile /Users/mac/.zlogin.
Installation of RVM in /Users/mac/.rvm/ is almost complete:

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

# mac,
#
#   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
MacdeMacBook-Pro:~ mac$ 
3. 檢查rvm版本:
MacdeMacBook-Pro:~ mac$ rvm -v
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
MacdeMacBook-Pro:~ mac$ 
4. 查出所有可用ruby版本:
MacdeMacBook-Pro:~ mac$ 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
MacdeMacBook-Pro:~ mac$ 
5. 安裝ruby 2.3.0版本:
MacdeMacBook-Pro:~ mac$ rvm install 2.3.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/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/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 new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/opt
/usr/local/sbin
/usr/local/share
/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/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown mac /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /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/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/mkdir -p /Users/mac/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/mac/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown mac /Users/mac/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 4131, done.
remote: Compressing objects: 100% (2754/2754), done.
remote: Total 4131 (delta 2094), reused 2652 (delta 1230), pack-reused 0
Receiving objects: 100% (4131/4131), 2.40 MiB | 49.00 KiB/s, done.
Resolving deltas: 100% (2094/2094), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
 * [new tag]         0.1        -> 0.1
 * [new tag]         0.2        -> 0.2
 * [new tag]         0.3        -> 0.3
 * [new tag]         0.4        -> 0.4
 * [new tag]         0.5        -> 0.5
 * [new tag]         0.6        -> 0.6
 * [new tag]         0.7        -> 0.7
 * [new tag]         0.7.1      -> 0.7.1
 * [new tag]         0.8        -> 0.8
 * [new tag]         0.8.1      -> 0.8.1
 * [new tag]         0.9        -> 0.9
 * [new tag]         0.9.1      -> 0.9.1
 * [new tag]         0.9.2      -> 0.9.2
 * [new tag]         0.9.3      -> 0.9.3
 * [new tag]         0.9.4      -> 0.9.4
 * [new tag]         0.9.5      -> 0.9.5
 * [new tag]         0.9.8      -> 0.9.8
 * [new tag]         0.9.9      -> 0.9.9
 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.0.1      -> 1.0.1
 * [new tag]         1.0.2      -> 1.0.2
 * [new tag]         1.0.3      -> 1.0.3
 * [new tag]         1.0.4      -> 1.0.4
 * [new tag]         1.0.5      -> 1.0.5
 * [new tag]         1.0.6      -> 1.0.6
 * [new tag]         1.0.7      -> 1.0.7
 * [new tag]         1.0.8      -> 1.0.8
 * [new tag]         1.0.9      -> 1.0.9
 * [new tag]         1.1.0      -> 1.1.0
 * [new tag]         1.1.1      -> 1.1.1
HEAD is now at 89c3348 Merge pull request #1567 from cesarandreu/fix-diagnostic-conditonal
==> 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: 3768, done.
remote: Compressing objects: 100% (3657/3657), done.
remote: Total 3768 (delta 14), reused 309 (delta 1), pack-reused 0
Receiving objects: 100% (3768/3768), 3.01 MiB | 51.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Checking connectivity... done.
Tapped 3646 formulae (3,795 files, 9.3M)
Already up-to-date.
==> Installation successful!
==> Next steps
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
Installing requirements for osx.
Updating system.......
Error running 'requirements_osx_brew_update_system ruby-2.3.0',
showing last 15 lines of /Users/mac/.rvm/log/1480093522_ruby-2.3.0/update_system.log
    https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.'
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'Failed to update Homebrew, follow instructions here:
    https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.\n'
Failed to update Homebrew, follow instructions here:
    https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.
++ return 1
Requirements installation failed with status: 1.
6. 更新 Homebrew:
MacdeMacBook-Pro:~ mac$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out
MacdeMacBook-Pro:~ mac$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
curl: (22) The requested URL returned error: 404 Not Found
MacdeMacBook-Pro:~ mac$ brew install autoconf automake libtool
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle
######################################################################## 100.0%
==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
??  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Downloading https://homebrew.bintray.com/bottles/automake-1.15.sierra.bottle
######################################################################## 100.0%
==> Pouring automake-1.15.sierra.bottle.2.tar.gz
??  /usr/local/Cellar/automake/1.15: 130 files, 2.9M
==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6_1.sierra.bott

curl: (7) Failed to connect to homebrew.bintray.com port 443: Operation timed out
Error: Failed to download resource "libtool"
Download failed: https://homebrew.bintray.com/bottles/libtool-2.4.6_1.sierra.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Using the sandbox
==> Downloading https://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.xz
==> Downloading from http://ftp.kaist.ac.kr/gnu/gnu/libtool/libtool-2.4.6.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libtool/2.4.6_1 --program-prefix=g --
==> make install
==> Caveats
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> Summary
??  /usr/local/Cellar/libtool/2.4.6_1: 71 files, 3.7M, built in 41 seconds
7. 安裝ruby2.3.0:
MacdeMacBook-Pro:~ mac$ rvm install 2.3.0 
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/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.
Installing requirements for osx.
Updating system.....
Installing required packages: 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/mac/.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  20422      0  0:11:34  0:11:34 --:--:-- 23365
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/mac/.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/mac/.rvm/gems/ruby-2.3.0@global
ruby-2.3.0 - #importing gemset /Users/mac/.rvm/gemsets/global.gems.............|
ruby-2.3.0 - #generating global wrappers........
ruby-2.3.0 - #gemset created /Users/mac/.rvm/gems/ruby-2.3.0
ruby-2.3.0 - #importing gemsetfile /Users/mac/.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
MacdeMacBook-Pro:~ mac$ 
8. 檢查ruby版本,此時不出意外ruby版本應(yīng)該為2.3.0 了:
MacdeMacBook-Pro:~ mac$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16]
MacdeMacBook-Pro:~ mac$ 
MacdeMacBook-Pro:~ mac$ rvm list

rvm rubies

=* ruby-2.3.0 [ x86_64 ]

# => - current //當(dāng)前版本
# =* - current && default //當(dāng)前且默認版本
#  * - default //默認版本

MacdeMacBook-Pro:~ mac$ 
9. 查看ruby源:
MacdeMacBook-Pro:~ mac$ gem sources -l
*** CURRENT SOURCES ***

https://rubygems.org/
MacdeMacBook-Pro:~ mac$ 
10. 移除默認ruby源:
MacdeMacBook-Pro:~ mac$ gem sources -r https://rubygems.org/
https://rubygems.org/ removed from sources
MacdeMacBook-Pro:~ mac$ gem sources -l
*** CURRENT SOURCES ***

MacdeMacBook-Pro:~ mac$ 
11. 添加ruby-china 源:
MacdeMacBook-Pro:~ mac$ gem sources -a https://gems.ruby-china.org/
https://gems.ruby-china.org/ added to sources
MacdeMacBook-Pro:~ mac$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.org/
MacdeMacBook-Pro:~ mac$ 
12. 安裝cocoapods:
MacdeMacBook-Pro:~ mac$ gem install cocoapods
Fetching: nanaimo-0.2.2.gem (100%)
Successfully installed nanaimo-0.2.2
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.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: 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-4.2.7.1.gem (100%)
Successfully installed activesupport-4.2.7.1
Fetching: xcodeproj-1.4.1.gem (100%)
Successfully installed xcodeproj-1.4.1
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
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: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
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.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: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
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 colored-1.2
Installing ri documentation for colored-1.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 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-4.2.7.1
Installing ri documentation for activesupport-4.2.7.1
Parsing documentation for xcodeproj-1.4.1
Installing ri documentation for xcodeproj-1.4.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
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 escape-0.0.4
Installing ri documentation for escape-0.0.4
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.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 fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
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
Done installing documentation for nanaimo, colored, claide, CFPropertyList, thread_safe, tzinfo, i18n, activesupport, xcodeproj, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, cocoapods-core, cocoapods after 14 seconds
25 gems installed
MacdeMacBook-Pro:~ mac$ 
13. 查看cocoapods 版本:
MacdeMacBook-Pro:~ mac$ pod --version
1.1.1
MacdeMacBook-Pro:~ mac$
14. 安裝zsh供鸠,方便后面使用 du -sh * 命令查看文件下載進度:
MacdeMacBook-Pro:repos mac$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Cloning Oh My Zsh...
Cloning into '/Users/mac/.oh-my-zsh'...
remote: Counting objects: 823, done.
remote: Compressing objects: 100% (693/693), done.
remote: Total 823 (delta 20), reused 683 (delta 9), pack-reused 0
Receiving objects: 100% (823/823), 559.90 KiB | 300.00 KiB/s, done.
Resolving deltas: 100% (20/20), done.
Checking connectivity... done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
Time to change your default shell to zsh!
Changing shell for mac.
Password for mac: 
         __                                     __   
  ____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                        /____/                       ....is now installed!

Please look over the ~/.zshrc file to select plugins, themes, and options.

p.s. Follow us at https://twitter.com/ohmyzsh.

p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.
MacdeMacBook-Pro:~ mac$ 
15. 下載cocoapods文件畦贸,期間可能報錯,如下:
MacdeMacBook-Pro:~ mac$ pod --version
1.1.1
MacdeMacBook-Pro:~ mac$ pod search AFNetworking
Setting up CocoaPods master repo
Setup completed
Creating search index for spec repo 'master'.. Done!
[!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`

[!] Skipping `0` because the podspec contains errors.

[!] Skipping `1` because the podspec contains errors.

[!] Skipping `2` because the podspec contains errors.

[!] Skipping `3` because the podspec contains errors.

[!] Skipping `4` because the podspec contains errors.

[!] Skipping `5` because the podspec contains errors.

[!] Skipping `6` because the podspec contains errors.

[!] Skipping `7` because the podspec contains errors.

[!] Skipping `8` because the podspec contains errors.

[!] Skipping `9` because the podspec contains errors.

[!] Skipping `a` because the podspec contains errors.

[!] Skipping `b` because the podspec contains errors.

[!] Skipping `c` because the podspec contains errors.

[!] Skipping `d` because the podspec contains errors.

[!] Skipping `e` because the podspec contains errors.

[!] Skipping `f` because the podspec contains errors.
MacdeMacBook-Pro:~ mac$ 
16. 解決Unable to find a pod with name, author, summary, or description matching AFNetworking錯誤:
rm ~/Library/Caches/CocoaPods/search_index.json
17. 進到repos文件夾下楞捂,使用 du -sh *命令薄坏,查看repos文件大小(此文件下載完畢應(yīng)該為358兆左右寨闹,下載完畢后應(yīng)該會自動解壓一些文件胶坠,最終大小為889兆左右,由于都是零碎小文件鼻忠,因此這一步請耐心等待):
 cd /Users/mac/.cocoapods/repos
**?  ****repos** du -sh *
3M master
**?  ****repos** 
58M master
**?  ****repos** du -sh *
215M master
**?  ****repos** du -sh *
358M master
**?  ****repos** du -sh *
358M master
**?  ****repos** du -sh *
597M master
**?  ****repos** du -sh *
893M master
**?  ****repos** du -sh *

18. 再次運行涵但,結(jié)果如下則證明cocoapods安裝完畢且能使用了:
MacdeMacBook-Pro:~ mac$ rm ~/Library/Caches/CocoaPods/search_index.json
MacdeMacBook-Pro:~ mac$ pod search AFNetworking
Creating search index for spec repo 'master'.. Done!
-> AFNetworking (3.1.0)
   A delightful iOS and OS X networking framework.
   pod 'AFNetworking', '~> 3.1.0'
   - Homepage: https://github.com/AFNetworking/AFNetworking
   - Source:   https://github.com/AFNetworking/AFNetworking.git
   - Versions: 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 3.0.0-beta.3,
   3.0.0-beta.2, 3.0.0-beta.1, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.4, 2.5.3, 2.5.2,
   2.5.1, 2.5.0, 2.4.1, 2.4.0, 2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0,
   2.1.0, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2, 2.0.0-RC1, 1.3.4,
   1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2,
   1.0RC1, 0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0, 0.5.1 [master repo]
   - Subspecs:
     - AFNetworking/Serialization (3.1.0)
     - AFNetworking/Security (3.1.0)
     - AFNetworking/Reachability (3.1.0)
     - AFNetworking/NSURLSession (3.1.0)
     - AFNetworking/UIKit (3.1.0)
.....

二、rbenv 安裝ruby

1. 安裝brew,使用brew可以幫我們安裝下載一些軟件:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. 使用brew安裝rbenv:
 brew install rbenv
3. 安裝ruby-build:
 git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
4. 安裝 ruby-china 鏡像:
git clone https://github.com/andorchen/rbenv-china-mirror.git ~/.rbenv/plugins/rbenv-china-mirror
5. 使用 rbenv 安裝 ruby 帖蔓,這里我們選擇2.3.0:
rbenv install 2.3.0

6. 設(shè)置全局的 ruby 版本矮瘟,默認是2.0.0:
rbenv global 2.3.0
7. 去掉原生的 gem 源,替換為 ruby-china 源:
gem sources --a https://gems.ruby-china.org/  
gem sources --r https://rubygems.org/  
8. 更新 gem 版本:
gem update --system
9. 安裝所需要的 CocoaPods:
gem install cocoapods -v 1.1.1
以下是通過rbenv 安裝的過程塑娇,一些重要安裝步驟的截圖記錄澈侠,以供參考:
rbenv-01.jpg
rbenv-02.png
rbenv-03.png

以上就是通過rbenv 安裝ruby ,安裝成功后埋酬,切換默認ruby版本哨啃,最后安裝cocoapods即可。

總結(jié):出現(xiàn)問題不是問題写妥,解決問題才是關(guān)鍵拳球!以上就是我在個人電腦與公司電腦上一些安裝記錄,也希望能幫助到與我遇到同樣問題的人珍特。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末祝峻,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子扎筒,更是在濱河造成了極大的恐慌莱找,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,839評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件嗜桌,死亡現(xiàn)場離奇詭異奥溺,居然都是意外死亡,警方通過查閱死者的電腦和手機骨宠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,543評論 2 382
  • 文/潘曉璐 我一進店門浮定,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人层亿,你說我怎么就攤上這事壶唤。” “怎么了棕所?”我有些...
    開封第一講書人閱讀 153,116評論 0 344
  • 文/不壞的土叔 我叫張陵闸盔,是天一觀的道長。 經(jīng)常有香客問我琳省,道長迎吵,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,371評論 1 279
  • 正文 為了忘掉前任针贬,我火速辦了婚禮击费,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘桦他。我一直安慰自己蔫巩,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 64,384評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著圆仔,像睡著了一般垃瞧。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上坪郭,一...
    開封第一講書人閱讀 49,111評論 1 285
  • 那天个从,我揣著相機與錄音,去河邊找鬼歪沃。 笑死嗦锐,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的沪曙。 我是一名探鬼主播奕污,決...
    沈念sama閱讀 38,416評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼液走!你這毒婦竟也來了菊值?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,053評論 0 259
  • 序言:老撾萬榮一對情侶失蹤育灸,失蹤者是張志新(化名)和其女友劉穎腻窒,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體磅崭,經(jīng)...
    沈念sama閱讀 43,558評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡儿子,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,007評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了砸喻。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片柔逼。...
    茶點故事閱讀 38,117評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖割岛,靈堂內(nèi)的尸體忽然破棺而出愉适,到底是詐尸還是另有隱情,我是刑警寧澤癣漆,帶...
    沈念sama閱讀 33,756評論 4 324
  • 正文 年R本政府宣布维咸,位于F島的核電站,受9級特大地震影響惠爽,放射性物質(zhì)發(fā)生泄漏癌蓖。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,324評論 3 307
  • 文/蒙蒙 一婚肆、第九天 我趴在偏房一處隱蔽的房頂上張望租副。 院中可真熱鬧,春花似錦较性、人聲如沸用僧。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,315評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽责循。三九已至糟港,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間沼死,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,539評論 1 262
  • 我被黑心中介騙來泰國打工崔赌, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留意蛀,地道東北人。 一個月前我還...
    沈念sama閱讀 45,578評論 2 355
  • 正文 我出身青樓健芭,卻偏偏與公主長得像县钥,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子慈迈,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,877評論 2 345

推薦閱讀更多精彩內(nèi)容