CocoaPods最新最全安装教程(转)

/****************2018-04-27更新内容************************/

更新内容:在多target中安装相同pod的优雅解决方案

# Podfile

platform :ios, '9.0'

use_frameworks!

# My other pods

def testing_pods
    pod 'Quick', '0.5.0'
    pod 'Nimble', '2.0.0-rc.1'
end

target 'MyTests' do
    testing_pods
end

target 'MyUITests' do
    testing_pods
end

记录性质的文章。

1>. 升级gem

sudo gem update --system

2>. 移除现有 Ruby 默认源

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

3>. 使用淘宝镜像源

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

如果出现

Error fetching https://ruby.taobao.org/:
    bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

则替换为gem sources -a https://gems.ruby-china.com/,一切出现404问题,都可以访问https://gems.ruby-china.org解决

image.png

4>. 验证当前镜像源

gem sources -l

5>. 安装cocoapods

 系统升级 OS X EL Capitan 前:sudo gem install cocoapods
 系统升级 OS X EL Capitan 后:sudo gem install -n /usr/local/bin 
cocoapods(使用这个!)

6>. 如果步骤5成功则执行pod setup,成功后执行pod -version 检查版本

 如果失败,比如:Error installing cocoapods:  activesupport requires Ruby version >= 2.2.2. 则说明当前的ruby版本低于2.2.2,然后进行第7.

7>. 安装 RVM (ruby 版本管理器)

curl -L get.rvm.io | bash -s stable
//________等安装完成 出现下面这行提示以下___________
In case of problems: https://rvm.io/helpandhttps://twitter.com/rvm_io

8>. 执行

$source ~/.bashrc  
$source ~/.bash_profile  

9>. 检查rvm版本,看是否安装成功

rvm -v 
//________提示以下___________
rvm 1.27.0 (latest) by Wayne E. Seguin, Michal Papis[https://rvm.io/]

10>. 使用rvm查看管理的所有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-headruby-head
...# for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2
...# JRuby

11>. 升级ruby

rvm install 2.2.2

12>. 安装homebrew

情形1:
//________提示以下___________
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) 
如果出现以上信息可以直接回车,会安装homebrew相关的管理工具。

情形2:
//________提示以下___________
Error running 'requirements_osx_brew_update_system ruby-2.3.0',
showing last 15 lines of /Users/peter/.rvm/log/1481169271_ruby-2.3.0/update_system.log
https://github.com/Homebrew/homebrew/wiki/Common-Issues
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ 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
++ return 1
Requirements installation failed with status: 1.
如果出现以上信息可以执行命令:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
附homebrew官网:http://brew.sh/index_zh-cn.html

13>. 等12步homebrew安装完后再执行

rvm install ruby-2.3.0
//________成功提示___________
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/Peter/.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/Peter/.rvm/gems/ruby-2.3.0@global
ruby-2.3.0 - #importing gemset /Users/Peter/.rvm/gemsets/global.gems...........|
ruby-2.3.0 - #generating global wrappers........
ruby-2.3.0 - #gemset created /Users/Peter/.rvm/gems/ruby-2.3.0
ruby-2.3.0 - #importing gemsetfile /Users/Peter/.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

//________错误提示___________
There was an error(56).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
No fallback URL could be found, try increasing timeout with:

echo "export rvm_max_time_flag=20" >> ~/.rvmrc

There has been an error fetching the ruby interpreter. Halting the installation.
解决办法:版本号只保留2位,改为命令rvm install 2.3即可

14>. 检查ruby版本

ruby -v
//________成功提示___________
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

15>. 执行

sudo gem install -n /usr/local/bin cocoapods
//________提示___________
Fetching: nanaimo-0.2.3.gem (100%)
Successfully installed nanaimo-0.2.3
Fetching: colored-1.2.gem (100%)
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
...
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%)
ERROR:  While executing gem ... (TypeError)
no implicit conversion of nil into String

16>. 上边出错后更新gem

gem update --system 
//________成功提示___________
RubyGems system software updated

17>. 再执行

sudo gem install -n /usr/local/bin cocoa pods

18>. 执行

pod setup

19>. 如果出现下面问题:

Setting up CocoaPods master repo
[!] /usr/local/bin/Git clone https://github.com/CocoaPods/Specs.git master

Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

依次执行:
sudo gem uninstall cocoa pods
pod repo remove master
sudo gem install -n /usr/local/bin cocoa pods
pod setup

20>. 如果第19步没有问题,表示安装OK,会看到如下信息

CocoaPods 1.2.0.beta.1 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.2.0.beta.1

Setup completed

21>. 再检查版本

pod --version
出现:1.1.1

到此安装步骤全部完成!!!以上是我的安装步骤,也可以参照:http://blog.csdn.net/sharktoping/article/details/52311460

如果看不到最新版本,请使用 pod repo update 命令更新一下本地pod仓库

pod另一现象和解决办法

现象:[!] Unable to find a pod with name, author, summary, or description matching `YYkit`
解决办法: rm ~/Library/Caches/CocoaPods/search_index.json

作者:行走在冬夜的冷风中哦哦哦
链接://www.greatytc.com/p/d6b703eb72f4
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,884评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,347评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,435评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,509评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,611评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,837评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,987评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,730评论 0 267
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,194评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,525评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,664评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,334评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,944评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,764评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,997评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,389评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,554评论 2 349

推荐阅读更多精彩内容