安装淘宝源就直接跳过,安装十余次,分享下最近安装cocoapods的经验,仅仅提醒ruby版本问题之后的操作.如果还有不懂地方可以下方评论,会及时回答.
1
2 Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
1.安装ruby
1>安装 RVM
RVM: Ruby Version Manager, Ruby的版本管理器,包括Ruby的版本管理和Gem库管理(gemset)
1 | curl -L get.rvm.io | bash -s stable |
2>安装home-brew(切记先安装home-brew,再安装ruby!!)
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
home-brew地址: http://brew.sh
如果出现重复安装home-brew,不要怕.
会给你提示命令.
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
1 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" |
3>再安装ruby版本(最新版本2.3.0)
1 | rvm install 2.3.0 |
出现情况:
1.安装不通过的话可以进行手动安装.
Installing requirements for osx.
Updating system…..
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl|
……..
Error running ‘requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl’,
showing last 15 lines of /Users/MTKJ/.rvm/log/1469285314_ruby-2.3.0/package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libksba_openssl.log
1 | brew install autoconf |
2 . Error running ‘__rvm_make -j 1’ 错误
ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/xxxx/.rvm/src/ruby-2.3.0…-
ruby-2.3.0 - #configuring………………………………………………|
ruby-2.3.0 - #post-configuration.
ruby-2.3.0 - #compiling………..
Error running ‘__rvm_make -j 1’,
showing last 15 lines of /Users/xxxx/.rvm/log/1476689284_ruby-2.3.0/make.log
compiling dln.c
compiling localeinit.c
creating verconf.h
verconf.h updated
compiling loadpath.c
compiling prelude.c
linking static-library libruby.2.3.0-static.a
verifying static-library libruby.2.3.0-static.a
linking shared-library libruby.2.3.0.dylib
generating encdb.h
encdb.h updated
making enc
/bin/sh: /Applications/Xcode: No such file or directory
make: *** [enc] Error 127
++ return 2
There has been an error while running make. Halting the installation.
/Users/xxxx/.rvm/bin/rvm: line 66: shell_session_update: command not found
- 安装xcode command line 后再次安装ruby.
1 | xcode-select --install |
- 如果还是没有成功,查看自己xcode command line 是否选在正确版本.
4>出现错误了,还是没有安装成功ruby.(没关系,卸载RVM,从新安装!)
要记得关闭终端重新打开, 或者打开路径cd ~
出现在~
1 | sudo rm -rf .rvm .rvmrc /etc/rvmrc ;gem uninstall rvm |
2.安装CocoaPods
1>安装cocoapods(普通版本)
1 | sudo gem install cocoapods |
2>更新框架库
1 | pod setup |
可以查看框架镜像库的cd ~/.cocoapods
3>更新cocoapods版本(测试版本,仅供特定条件)
1 | sudo gem install cocoapods --pre |
4>指定安装cocoapods版本
1 | sudo gem install cocoapods --version 1.0.1 |
出现情况:
- Could not find a valid gem ‘cocoapods’ (>= 0), here is why:
问题是因为gem 的ruby 镜像源发生了更换,切换镜像源即可。Unable to download data from https://gems.ruby-china.org - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
1 | https://gems.ruby-china.org => https://gems.ruby-china.com |
详情可参照ruby中国镜像社区: https://gems.ruby-china.com/