美文网首页iOS开发专题文章收藏
Mac 下 cocoapods的配置安装

Mac 下 cocoapods的配置安装

作者: Ucself | 来源:发表于2016-10-26 15:30 被阅读19次

前言

由于项目开发需要运用第三发库太多了,每下载一个第三个库都要去查看他的配置介绍然而就会一个一个的去引用系统的库,还有第三方库的管理问题,于是前段时间选择使用cocoapods 进行管理。每个程序员都有两台电脑(一台公司的,一台自己的),在公司配置完成,经过重重配置遇到问题解决,终于配置完成。突然发现自己电脑也要配置,然后之前遇到的问题也一个一个的又去查(这不是坑自己吗)。算了作为程序员还是写点博客比较好,记录自己所遇到的问题和自己的知识;方便你我,方便阅读的人。

标签

RVM,Ruby,CocoaPods

安装 RVM

RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)
向终端输入以下代码安装RVM

$ curl -L get.rvm.io | bash -s stable

指定源

$ 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/]

使用RVM 升级或者安装Ruby

Ruby一般Mac系统都会自带不需要安装升级,但是我安装的时候遇到Ruby版本过低提示错误信息Error installing pods:activesupport requires Ruby version >= 2.2.2.,所以需要rvm对Ruby进行升级
终端输入

$ ruby -v

可查看当前系统Ruby版本

ruby 2.0.0p648 (2015-12-16 revision 53155) [x86_64-darwin15]

所以我们需要对ruby进行升级
查看rvm版本

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

安装Ruby 输入

rvm install 2.2

终端输出太长,就不打印了

使用Ruby 安装CocoaPods

使用淘宝的Ruby镜像访问cocoapods,官方代码

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l

两句命令结果分别是

https://gems.ruby-china.org/ added to sources
#这个我已经切换过了
source https://rubygems.org/ not present in cache 
*** CURRENT SOURCES ***

https://ruby.taobao.org/
https://gems.ruby-china.org/

接下来就直接安装CocoaPods

sudo gem install cocoapods

终端输出表示成功

Password:
Fetching: activesupport-4.2.7.1.gem (100%)
Successfully installed activesupport-4.2.7.1
Fetching: claide-1.0.1.gem (100%)
Successfully installed claide-1.0.1
Fetching: cocoapods-core-1.1.1.gem (100%)
Successfully installed cocoapods-core-1.1.1
Fetching: cocoapods-downloader-1.1.2.gem (100%)
Successfully installed cocoapods-downloader-1.1.2
Fetching: cocoapods-trunk-1.1.1.gem (100%)
Successfully installed cocoapods-trunk-1.1.1
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: gh_inspector-1.0.2.gem (100%)
Successfully installed gh_inspector-1.0.2
Fetching: molinillo-0.5.2.gem (100%)
Successfully installed molinillo-0.5.2
Fetching: xcodeproj-1.3.3.gem (100%)
Successfully installed xcodeproj-1.3.3
Fetching: cocoapods-1.1.1.gem (100%)
Successfully installed cocoapods-1.1.1
Parsing documentation for activesupport-4.2.7.1
Installing ri documentation for activesupport-4.2.7.1
Parsing documentation for claide-1.0.1
Installing ri documentation for claide-1.0.1
Parsing documentation for cocoapods-core-1.1.1
Installing ri documentation for cocoapods-core-1.1.1
Parsing documentation for cocoapods-downloader-1.1.2
Installing ri documentation for cocoapods-downloader-1.1.2
Parsing documentation for cocoapods-trunk-1.1.1
Installing ri documentation for cocoapods-trunk-1.1.1
Parsing documentation for fourflusher-2.0.1
Installing ri documentation for fourflusher-2.0.1
Parsing documentation for gh_inspector-1.0.2
Installing ri documentation for gh_inspector-1.0.2
Parsing documentation for molinillo-0.5.2
Installing ri documentation for molinillo-0.5.2
Parsing documentation for xcodeproj-1.3.3
Installing ri documentation for xcodeproj-1.3.3
Parsing documentation for cocoapods-1.1.1
Installing ri documentation for cocoapods-1.1.1
Done installing documentation for activesupport, claide, cocoapods-core, cocoapods-downloader, cocoapods-trunk, fourflusher, gh_inspector, molinillo, xcodeproj, cocoapods after 12 seconds
10 gems installed

再进行pod安装

$pod setup

下一篇进行cocoapods 使用pod 项目操作

相关文章

网友评论

    本文标题:Mac 下 cocoapods的配置安装

    本文链接:https://www.haomeiwen.com/subject/efgduttx.html