/****************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解决
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
作者:行走在冬夜的冷风中哦哦哦
链接:http://www.jianshu.com/p/d6b703eb72f4
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
网友评论