前言:
最近用回cocoapods,猛然发现一年前装的cocoapods已经出现了问题,pod install指令后并不能自动生成workspace,控制台输出为;
$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing SVProgressHUD (2.1.2)
Generating Pods project
Abort trap: 6
卸载cocoapods后重新安装会出现如下错误:
ERROR: While executing gem ... (OpenSSL::SSL::SSLError)
hostname "gems.ruby-china.org" does not match the server certificate
经过多方探索,基本猜到了问题:ruby版本太低了,我用的是2.2.2,是当时使用cocoapods的最低门槛,不知为何现在不行了。
既然定位了问题,我就索性重新安装了一遍,顺便记录一下安装步骤
安装环境:macOS 10.12.6
步骤:
- 若未安装rvm,则先安装rvm:
打开终端:$ curl -L https://get.rvm.io | bash -s stable
然后,载入 RVM 环境 $ source ~/.rvm/scripts/rvm
检查是否安装成功: $ rvm -v
若输入上面口令后显示:
rvm 1.27.0 (latest) by Wayne E. Seguin<wayneeseguin@gmail.com>,Michal Papis <mpapis@gmail.com> [https://rvm.io/]
表明安装成功
- 正式开始:
用
$ ruby -v
查看当前 ruby 的版本用
$ rvm list known
查看ruby所有的版本,我当时只能看到2.3,说明rvm不是最新的(rvm是一个便捷的多版本ruby环境的管理和切换工具)-
更新 rvm :
$ rvm get stable
(若能看到版本2.4则不用执行此操作)执行完再用
$ 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[.10] [ruby-]2.2[.6] [ruby-]2.3[.3] [ruby-]2.4[.0] ruby-head
-
$ rvm install 2.4
$ rvm install 2.4 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.12/x86_64/ruby-2.4.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: coreutils, openssl@1.1..... Certificates in '/usr/local/etc/openssl@1.1/cert.pem' are already up to date. Requirements installation successful. Installing Ruby from source to: /Users/Apple/.rvm/rubies/ruby-2.4.0, this may take a while depending on your cpu(s)... ruby-2.4.0 - #downloading ruby-2.4.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 11.9M 100 11.9M 0 0 56257 0 0:03:43 0:03:43 --:--:-- 27587 ruby-2.4.0 - #extracting ruby-2.4.0 to /Users/Apple/.rvm/src/ruby-2.4.0.... ruby-2.4.0 - #configuring......................................................- ruby-2.4.0 - #post-configuration. ruby-2.4.0 - #compiling........................................................| ruby-2.4.0 - #installing....... ruby-2.4.0 - #making binaries executable.. ruby-2.4.0 - #downloading rubygems-2.6.12 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 749k 100 749k 0 0 645k 0 0:00:01 0:00:01 --:--:-- 645k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.4.0 - #extracting rubygems-2.6.12.... ruby-2.4.0 - #removing old rubygems......... ruby-2.4.0 - #installing rubygems-2.6.12......................... ruby-2.4.0 - #gemset created /Users/Apple/.rvm/gems/ruby-2.4.0@global ruby-2.4.0 - #importing gemset /Users/Apple/.rvm/gemsets/global.gems...........| ruby-2.4.0 - #generating global wrappers........ ruby-2.4.0 - #gemset created /Users/Apple/.rvm/gems/ruby-2.4.0 ruby-2.4.0 - #importing gemsetfile /Users/Apple/.rvm/gemsets/default.gems evaluated to empty gem list ruby-2.4.0 - #generating default wrappers........ ruby-2.4.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.4.0 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
更新过程中可见顺带着将 gem 更新到了2.6.12
-
$ rvm list
$ rvm list rvm rubies * ruby-2.2.2 [ x86_64 ] => ruby-2.4.0 [ x86_64 ] # => - current # =* - current && default # * - default
发现rvm的默认版本还不是2.4.0
$ rvm --default use 2.4.0
改变默认版本为2.4.0-
$ gem source -l
查看 ruby 源若是
*** CURRENT SOURCES *** https://rubygems.org/
则将其换为国内的源
gem sources --add https://ruby.taobao.org gem sources --remove https://rubygems.org/
国内两个可用源都可以:
https://ruby.taobao.org https://gems.ruby-china.org
-
更新gem看是否还有内容需要更新
$ sudo gem update -n /usr/local/bin —system
-
卸载旧的cocoapods(如果有的话)
$ sudo gem uninstall cocoapods
-
安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
完成:
Done installing documentation for nanaimo, colored2, claide, CFPropertyList, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, fuzzy_match, thread_safe, tzinfo, i18n, activesupport, cocoapods-core, cocoapods after 18 seconds 26 gems installed
-
$ pod install
试试$ pod install Analyzing dependencies Downloading dependencies Installing AFNetworking (3.1.0) Installing SVProgressHUD (2.1.2) Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `remember.xcworkspace` for this project from now on. Sending stats Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
成功生成workspace!