cocoa pods

本篇为转发文章 

原文链接 【iOS工具】rvm、Ruby环境和CocoaPods安装使用及相关报错问题解决(2016.12.15 更新)

还有以前的不错的链接 CocoaPods安装和使用教程

【iOS工具】rvm、Ruby环境和CocoaPods安装使用及相关报错问题解决

作者苜蓿鬼仙

〇、前言

在iOS开发中CocoaPods作为库依赖管理工具就是一把利器。

有了CocoaPods则无需再通过拖第三方库及第三方库所依赖的framework静态库到项目中等麻烦的操作,仅仅只需要通过终端(Terminal)输入一些指令即可完成这些操作;而且涉及到第三方库的更新升级也可以通过CocoaPods进行手动管理更新。

方便快捷!赶快行动起来吧!!!

一、Homebrew、Rvm、Ruby、CocoaPods 简介

1、官网及相关链接

Rvm 官网https://www.rvm.io/

Ruby 官网https://rubygems.org/

CocoaPods 官网https://cocoapods.org/

Rvm 安装指南:https://rvm.io/rvm/install

Homebrew 官网:http://brew.sh/index_zh-cn.html

ruby 镜像 - taobao:https://ruby.taobao.org/

ruby 镜像 - china:https://gems.ruby-china.org/

2、Homebrew 介绍

Homebrew是一个软件包管理器,用于在mac上安装一些os x上没有的UNiX工具;类似于360软件管理器。

3、Rvm 介绍

Rvm全称Ruby Version Manager,是安装和管理ruby的一种工具。

摘录:RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

4、Ruby 介绍

Ruby是一种面向对象的脚本语言,简单易用,功能强大。能跨平台和可移植性好等等。其实就是种脚本语言。

Ruby的软件源使用的是亚马逊的云服务,国内网络环境下载时可能会出现各种不稳定和超时,所以自带的需要翻墙,可以将官方 ruby 源替换成国内淘宝 ruby 源(https://ruby.taobao.org/)或者是由China ruby 源(https://gems.ruby-china.org/)。据消息了解,2016.06淘宝源暂停维护了,建议使用China ruby 源。

5、CocoaPods 介绍

CocoaPods是 iOS 最常用的第三方类库管理工具,绝大部分有名的开源类库都支持CocoaPods。

CocoaPods是用ruby实现的,要想使用它首先需要有ruby的环境。幸运的是OS X系统默认已经可以运行ruby了。但是有时候ruby版本过低是无法正常支持CocoaPods的使用,所以需要先安装更新升级rvm和ruby。

二、CocoaPods 安装使用

1、检查安装 rvm 环境( 正常情况可直接略过此步骤 )

检查当前rvm环境( 此处检查是否存在rvm环境 ):

$rvm -v

`输出结果:( 存在 rvm 环境)`muxuguixiandeMacBook-Pro:~ jijiucheng$ rvm -vrvm1.27.0(latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

`输出结果:(不存在 rvm 环境)`muxuguixiandeMacBook-Pro:~ jijiucheng$ rvm -v-bash: rvm:commandnotfound

情况一:如果不存在rvm环境,先安装配置rvm环境;

① 期间可能会问你 `sudo管理员` 密码,以及自动通过 `homebrew` 安装依赖包;

等待一段时间后就可以成功安装好 `rvm`。

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

输出结果:(下载安装)(显示的 `` 代表一行空格)muxuguixiandeMacBook-Pro:~ jijiucheng$ curl -Lhttps://get.rvm.io | bash -s stable% Total    % Received % Xferd  Average Speed  Time    Time    Time  Current Dload  Upload  Total  Spent    Left  Speed100184100184009300:00:010:00:01--:--:--    93100228651002286500896400:00:020:00:02--:--:--  710kDownloadinghttps://github.com/rvm/rvm/archive/1.27.0.tar.gzDownloadinghttps://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.ascFound PGP signatureat:'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc',but no GPG software existstovalidateit, skipping.```Installing RVMto/Users/smalllufeinj/.rvm/`Adding rvm PATHlineto/Users/smalllufeinj/.profile /Users/smalllufeinj/.mkshrc /Users/smalllufeinj/.bashrc /Users/smalllufeinj/.zshrc.Adding rvm loadinglineto/Users/smalllufeinj/.profile /Users/smalllufeinj/.bash_profile /Users/smalllufeinj/.zlogin.`InstallationofRVMin/Users/smalllufeinj/.rvm/ is almost complete:```.* TostartusingRVM you needtorun `source /Users/smalllufeinj/.rvm/scripts/rvm`inall youropenshellwindows,inrare cases you needtoreopen allshellwindows.``# muxuguixian,##  Thank you for using RVM!#  We sincerely hope that RVM helps to make your life easier and more enjoyable!!!## ~Wayne, Michal & team.``Incaseofproblems:https://rvm.io/helpandhttps://twitter.com/rvm_io

下载安装 rvm 环境.png

② 然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)。

$source ~/.rvm/scripts/rvm

输出结果:(^_^)(什么都没有输出)muxuguixiandeMacBook-Pro:~ jijiucheng$source ~/.rvm/scripts/rvm

③ 再次检查 rvm 是否安装正确。

$rvm -v

`输出结果:( 存在 rvm 环境)`muxuguixiandeMacBook-Pro:~ jijiucheng$ rvm -vrvm1.27.0(latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

情况二:如果存在rvm环境,用rvm安装ruby环境;

当ruby版本低于2.2.2时,安装CocoaPods会报错;为防止ruby版本过低,建议先升级ruby环境,建议升级到2.3.0版本以上。【可以通过$ ruby -v指令检查当前 ruby 版本】

① 查询已知的ruby环境。

$ rvmlistknown

输出结果:(显示的``代表一行空格)muxuguixiandeMacBook-Pro:~ jijiucheng$ rvm list known#MRIRubies[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 --branch2.2``#JRubyjruby-1.6[.8]jruby-1.7[.23]jruby[-9.0.5.0]jruby-head``#Rubiniusrbx-1[.4.3]rbx-2.3[.0]rbx-2.4[.1]rbx[-2.5.8]rbx-head``#Opalopal``#Minimalisticruby implementation -ISO30170:2012mruby[-head]``#RubyEnterpriseEditionree-1.8.6ree[-1.8.7][-2012.02]``#GoRubygoruby``#Topaztopaz``#MagLevmaglev[-head]maglev-1.0.0``#MacOSXSnowLeopardOrNewermacruby-0.10macruby-0.11macruby[-0.12]macruby-nightlymacruby-head``#IronRubyironruby[-1.1.3]ironruby-head

查询已知的 ruby 环境 .png

② 指定ruby版本进行更新( 此处按照ruby2.3.0版本进行更新 )。

$ rvm install2.3.0

输出结果:( 此处因为终端输出的字符过多,所以此处用截图方式 )

指定 ruby 版本进行更新 .png

③ 第二步需要一段时间等待,完成后此时 rvm 环境就配置好了;Ruby Gems 就安装好了。

④ 补充相关指令:

查询已安装的 ruby:

$ rvmlist

卸载一个已安装版本:

$ rvm remove1.9.2

2、检查更新 ruby 版本环境(正常情况下从此步骤开始)

CocoaPods是用gem ruby实现的,要想使用它首先需要有gem ruby的环境。且 MAC 的 OS X系统默认已经可以运行ruby。

此处建议gem ruby包环境升级到2.6.x以上。

检查gem ruby版本号:

$sudo gem -v

检查结果:( 默认情况下版本应该较低,建议升级到 )muxuguixiandeMacBook-Pro:localjijiucheng$ gem -v2.5.1

更新gem ruby版本号:

$gem update --system

更新成功:( 实际打印可能与此不同,但是成功了就会显示 Successfully )muxuguixiandeMacBook-Pro:localjijiucheng$ gemupdate--systemUpdating rubygems-updateFetching: rubygems-update-2.6.7.gem (100%)Successfully installed rubygems-update-2.6.7

此种提示:( 表示已经是最新的 gemruby环境 )muxuguixiandeMacBook-Pro:~ jijiucheng$ gemupdate--systemLatestversioncurrently installed. Aborting.

检查ruby 源

$ gem sources-l

检查结果:( 如果电脑没安装过 CocoaPods,此时应该是默认 ruby 源 )muxuguixiandeMacBook-Pro:~ jijiucheng$gem sources -l*** CURRENT SOURCES ***https://rubygems.org/

移除ruby 源

$ gem sources --r https://rubygems.org/

移除结果:muxuguixiandeMacBook-Pro:local jijiucheng$ gem sources --removehttps://rubygems.org/https://rubygems.org/ removed from sources

替换添加国内镜像源ruby-china 源,因为上面已经提到国内镜像源taobao 源已经停止维护了,所以此处替换的是ruby-china 源,且尽量确保只有一个ruby-china 源

$ gem sources --a https://gems.ruby-china.com

替换结果:muxuguixiandeMacBook-Pro:local jijiucheng$ gem sources --addhttps://gems.ruby-china.orghttps://gems.ruby-china.org addedtosources

再次检查此时的 ruby 源:( 已经变成了 ruby-china 源 )muxuguixiandeMacBook-Pro:localjijiucheng$ gem sources -l*** CURRENT SOURCES ***https://gems.ruby-china.org

3、安装 CocoaPods

安装 CocoaPods(sudo 表示管理员执行指令)(此处需要输入一次密码)

$ sudo gem install cocoapods

`注意点:<------------------------------> 此处有个注意点`由于 OS X 系统的不同,此处的指令也是有些变化:OS X10.11之前系统的安装 CocoaPods 指令: $ sudo gem install cocoapodsOS X10.11以后系统的安装 CocoaPods 指令: $ sudo gem install -n /usr/local/bin cocoa pods

安装结果:(正常情况打印没有这么多,此处是因为解决报错时,同时打印了这么多)muxuguixiandeMacBook-Pro:local jijiucheng$ sudo gem install cocoa podsPassword:<----------------------------------->// 此处需要输入一次密码 Fetching:ffi-1.9.14.gem (100%)Building native extensions.  This could takeawhile...Successfully installed ffi-1.9.14Fetching:thread_safe-0.3.5.gem (100%)Successfully installed thread_safe-0.3.5Fetching:tzinfo-1.2.2.gem (100%)Successfully installed tzinfo-1.2.2Fetching:i18n-0.7.0.gem (100%)Successfully installed i18n-0.7.0Fetching:concurrent-ruby-1.0.2.gem (100%)Successfully installed concurrent-ruby-1.0.2Fetching:activesupport-5.0.0.1.gem (100%)Successfully installed activesupport-5.0.0.1Fetching:cocoa-0.1.6.gem (100%)Successfully installed cocoa-0.1.6Parsing documentationforffi-1.9.14Installingridocumentationforffi-1.9.14Parsing documentationforthread_safe-0.3.5Installingridocumentationforthread_safe-0.3.5Parsing documentationfortzinfo-1.2.2Installingridocumentationfortzinfo-1.2.2Parsing documentationfori18n-0.7.0Installingridocumentationfori18n-0.7.0Parsing documentationforconcurrent-ruby-1.0.2Installingridocumentationforconcurrent-ruby-1.0.2Parsing documentationforactivesupport-5.0.0.1Installingridocumentationforactivesupport-5.0.0.1Parsing documentationforcocoa-0.1.6Installingridocumentationforcocoa-0.1.6Done installing documentationforffi, thread_safe, tzinfo, i18n, concurrent-ruby, activesupport, cocoa after34secondsFetching:pods-0.0.1.gem (100%)Successfully installed pods-0.0.1Parsing documentationforpods-0.0.1Installingridocumentationforpods-0.0.1Done installing documentationforpods after0seconds8gems installed<------------------ 此处有 gems installed 标志着安装 CocoaPods 成功 ------------------>

安装 CocoaPods .png

正常情况下此处会出现很大的坑,经常会出现各种报错问题,大多数是为ruby环境过低没有更新升级,或者是牵扯到rvm管理器环境的问题,在后面各种报错问题的解决方案的中会有提到。

4、配置 CocoaPods 环境

说明:此处为了做测试,在 MAC 桌面Desktop创建了一个工程CocoaPodsTestDemo。

第一步:cd到目录文件夹,回车enter(快速方式:直接将文件夹拖入到终端Terminal)。

$ cd/Users/jijiucheng/Desktop/CocoaPodsTestDemo

输入结果:((^_^)此时没有任何结果 )muxuguixiandeMacBook-Pro:~ jijiucheng$ cd/Users/jijiucheng/Desktop/CocoaPodsTestDemo

第二步(建议):如果不知道第三方库版本的情况下,建议先查找一下当前所需第三方库的最新版本,可以通过输入指令的方式完成。并且查询完成后输入wq返回之前终端Terminal页面。

$pod search'AFNetworking'

查询结果:(因为会查询输出所有与'AFNetworking'相关的第三方库,此处只输出部分,其中下面的“横线”代替实际打印的一行空格)muxuguixiandeMacBook-Pro:~ jijiucheng$ cd /Users/jijiucheng/Desktop/CocoaPodsTestDemo muxuguixiandeMacBook-Pro:CocoaPodsTestDemo jijiucheng$ pod search'AFNetworking'--------------------------(此处是输出结果)---------------------------> AFNetworking (3.1.0)A delightful iOSandOS X networking framework.pod'AFNetworking','~> 3.1.0'- Homepage: https://github.com/AFNetworking/AFNetworking- Source:  https://github.com/AFNetworking/AFNetworking.git- Versions:3.1.0,3.0.4,3.0.3,3.0.2,3.0.1,3.0.0,3.0.0-beta.3,3.0.0-beta.2,3.0.0-beta.1,2.6.3,2.6.2,2.6.1,2.6.0,2.5.4,2.5.3,2.5.2,2.5.1,2.5.0,2.4.1,2.4.0,2.3.1,2.3.0,2.2.4,2.2.3,2.2.2,2.2.1,2.2.0,2.1.0,2.0.3,2.0.2,2.0.1,2.0.0,2.0.0-RC3,2.0.0-RC2,2.0.0-RC1,1.3.4,1.3.3,1.3.2,1.3.1,1.3.0,1.2.1,1.2.0,1.1.0,1.0.1,1.0,1.0RC3,1.0RC2,1.0RC1,0.10.1,0.10.0,0.9.2,0.9.1,0.9.0,0.7.0,0.5.1[master repo]- Subspecs: - AFNetworking/Serialization (3.1.0) - AFNetworking/Security (3.1.0) - AFNetworking/Reachability (3.1.0) - AFNetworking/NSURLSession (3.1.0) - AFNetworking/UIKit (3.1.0)......(后面还有好多与'AFNetworking'相关的第三方库,此处不一一列举)

搜索 'AFNetworking' 打印结果.png

第三步:创建 Podfile 配置文件

$vim Podfile

回车跳转界面(如下):

指令 vim Podfile 后跳转界面 .png

①键盘输入i,进入Podfile配置文件的编辑模式,底部会变成:--INSERT--

Podfile配置文件编辑模式(如下):

Podfile 配置文件编辑模式 .png

② 通过固定语句编辑进行 Podfile 文件的配置:

Podfile 配置文件固定语句(如下):```说明:可能有些人看到的固定语句不一样,但是大同小异,基本上都能实现最终效果。`---># Uncomment this line to define a global platform for your projectplatform:ios,'8.0'target'CocoaPodsTestDemo'do# Uncomment this line if you're using Swift or would like to use dynamic frameworks# Pods for CocoaPodsTestDemopod'AFNetworking','~>3.1.0'pod'SDWebImage'pod'MBProgressHUD'pod'FMDB'pod'Masonry'pod'MJExtension'pod'MJRefresh'# use_frameworks!# pod 'ReactiveCocoa'end

Podfile 配置文件固定语句 .png

③ 当固定语句输入完毕之后,按一次 `Esc` 按键退出编辑模式,底部就没有 `-- INSERT --` 标识了;

再按一次 `shift + :` ( 英文输入法状态下 )组合,底部就会出现一个 `冒号 :` ;

最后再输入 `wq` 回车,返回到配置 Podfile 文件之前的界面;

此时 Podfile 文件就配置好了;

此时可以在 `CocoaPodsTestDemo` 文件夹下发现多了一个 `Podfile` 文件。

Podfile输入完毕之后(如下):

Podfile 输入完毕之后 .png

配置文件完成后新增 Podfile 文件 .png

第四步:下载第三方库文件到项目工程中

$ podinstall

下载输出(如下):muxuguixiandeMacBook-Pro:CocoaPodsTestDemo jijiucheng$ podinstallAnalyzing dependenciesDownloading dependenciesInstalling AFNetworking (3.1.0)Installing FMDB (2.6.2)Installing MBProgressHUD (1.0.0)Installing MJExtension (3.0.13)Installing MJRefresh (3.1.12)Installing Masonry (1.0.2)Installing SDWebImage (3.8.2)Generating PodsprojectIntegratingclientproject[!] PleasecloseanycurrentXcode sessionsanduse`CocoaPodsTestDemo.xcworkspace`forthisprojectfromnowon.Pod installationcomplete! Thereare7dependenciesfromthe Podfileand7total podsinstalled.

下载第三方库文件到项目工程中 .png

安装 CocoaPods 成功后项目文件变化 .png

第五步:此后打开项目工程只需要点击打开CocoaPodsTestDemo.xcworkspace文件即可

打开工程文件目录变化(如下):

所有的第三方库文件都在 `/CocoaPodsTestDemo/Pods/Pods` 文件夹目录下

打开工程文件目录变化 .png

三、CocoaPods 安装过程中报错问题解决

说明:此部分所列举的问题均是在执行相关指令时出现的报错

1、Rvm 环境搭建

报错一:

① Error running 'requirements_osx_brew_update_system ruby-2.3.0', showing last 15 lines of /Users/jijiucheng/.rvm/log/1475769205_ruby-2.3.0/update_system.log

② curl: (35) Server aborted the SSL handshake

① 报错指令:

$ rvm install2.3.0

② 报错信息:

Errorrunning 'requirements_osx_brew_update_system ruby-2.3.0',showing last 15 lines of /Users/jijiucheng/.rvm/log/1475769205_ruby-2.3.0/update_system.log............Requirements installation failed with status: 1.

curl: (35)Serveraborted the SSL handshake

报错信息 1.png

报错信息 2.png

③ 报错原因:

网络问题,因为需要翻墙,所以网络不稳定;建议选择 VPN,保证线路的稳定性。

④ 解决方案( 指令一行一行输入 ):

$cd/usr/local

$gitremoteset-urlorigingit://mirrors.ustc.edu.cn/brew.git

$ echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>>~/.bashrc

解决方案 .png

⑤ 方案链接:

方案解决链接 -- https://segmentfault.com/q/1010000004276750

报错二:

① Error running '__rvm_make -j 1',

showing last 15 lines of /Users/jijiucheng/.rvm/log/1475769349_ruby-2.3.0/make.log

① 报错指令:

$ rvm install2.3.0

② 报错信息:

Errorrunning '__rvm_make -j 1',showing last 15 lines of /Users/jijiucheng/.rvm/log/1475769349_ruby-2.3.0/make.log............There has been an error while running make. Halting the installation.

报错信息 .png

③ 报错原因:

缺少 Xcode 工具,xcode command line

④ 解决方案:

$ xcode-select--install

解决方案 .png

⑤ 方案链接:

方案解决链接 1 - http://stackoverflow.com/questions/35228481/error-running-rvm-make-install

方案解决链接 2 - http://www.th7.cn/Program/Ruby/201609/966343.shtml

报错三:

① Gemset '' does not exist, 'rvm ruby-2.3.0 do rvm gemset create ' first, or append '--create'.

① 报错指令:

$ rvm install2.3.0

② 报错信息:

muxuguixiandeMacBook-Pro:local jijiucheng$ rvminstall2.3.0Already installed ruby-2.3.0.Toreinstalluse:.rvm reinstall ruby-2.3.0.Gemset''doesnotexist,'rvm ruby-2.3.0 do rvm gemset create 'first,orappend'--create'.

报错信息 .png

③ 报错原因:

指令不对,已经存在 ruby-2.3.0 的文件残留,需要重新安装;

④ 解决方案:

$ rvm reinstall ruby-2.3.0

解决方案 .png

2、Ruby 环境搭建

报错一:

3、CocoaPods 安装

4、CocoaPods 配置使用

报错一:

① Setting up CocoaPods master repo

② [!] Unable to add a source with urlhttps://github.com/CocoaPods/Specs.gitnamedmaster. You can try adding it manually in~/.cocoapods/reposor viapod repo add.

① 报错指令:

$ podinstall

② 报错信息:

muxuguixiandeMacBook-Pro:NFCustomer jijiucheng$ podinstallSetting up CocoaPodsmasterrepo[!] Unabletoaddasourcewithurl`https://github.com/CocoaPods/Specs.git`named`master`.You can try adding it manuallyin`~/.cocoapods/repos`orvia`pod repo add`.

报错信息 .png

③ 报错原因:

由于安装了多个Xcode导致路径变了,需要变换路径:

sudo xcode-select -switch /Applications/Xcode.app

sudo xcode-select -switch /Applications/Xcode\ 2.app

④ 解决方案:

$ sudo xcode-select-switch/Applications/Xcode.app

解决方案 .png

⑤ 资料补充:

出现 Setting up CocoaPods master repo,说明 Cocoapods 在将它的信息下载到  ~/.cocoapods 里;

新创建终端窗口,输入 cd ~/.cocoapods ,回车,输入 du -sh *  命令来查看文件大小,

每隔几分钟查看一次,这个目录最终大小是100多M( 本人这里大概 800M + ),就是完成了。

⑥ 方案链接:

方案解决链接 1 - ios开发怎样卸载已经安装的cocoapod

方案解决链接 2 - CocoaPods安装和使用及问题:Setting up CocoaPods master repo

四、资料补充

1、指令补全

① Rvm 指令库

$ruby -v#  查看ruby 版本$rvm list known#  列出已知的 ruby 版本$rvm install2.3.0#  选择指定 ruby 版本进行更新$rvm get stable#  更新 rvm$rvmuse2.2.2#  切换到指定 ruby 版本$rvmuse2.2.2--default#  设置指定 ruby 版本为默认版本$rvm list#  查询已安装的 ruby 版本$rvm remove1.9.2#  卸载移除 指定 ruby 版本

$ curl -L https://get.rvm.io | bash-sstable#  安装 rvm 环境$ curl-sSL https://get.rvm.io | bash-sstable --ruby#  默认安装 rvm 最新版本$ curl-sSL https://get.rvm.io | bash-sstable --ruby=2.3.0#  安装 rvm 指定版本$source~/.rvm/scripts/rvm#  载入 rvm

② gem 指令库

$gem -v#  查看 gem 版本$gem source#  查看 gem 配置源$gem source -l#  查看 gem 配置源目录$gem sources -a url#  添加 gem 配置源(url 需换成网址)$gem sources --add url#  添加 gem 配置源(url 需换成网址)$gem sources -r url#  删除 gem 配置源(url 需换成网址)$gem sources --remove url#  删除 gem 配置源(url 需换成网址)$gem update#  更新 所有包$gem update --system#  更新 Ruby Gems 软件$$gem install rake#  安装 rake,从本地或远程服务器$gem install rake --remote#  安装 rake,从远程服务器$gem install watir -v1.6.2#  安装 指定版本的 watir$gem install watir --version1.6.2#  安装 指定版本的 watir$gem uninstall rake#  卸载 rake 包$gem list d#  列出 本地以 d 打头的包$gem query -n''[0-9]''--local#  查找 本地含有数字的包$gem search log --both#  查找 从本地和远程服务器上查找含有 log 字符串的包$gem search log --remoter#  查找 只从远程服务器上查找含有 log 字符串的包$gem search -r log#  查找 只从远程服务器上查找含有log字符串的包$$gem help#  提醒式的帮助$gem help install#  列出 install 命令 帮助$gem help examples#  列出 gem 命令使用一些例子$gem build rake.gemspec#  把 rake.gemspec 编译成 rake.gem$gem check -v pkg/rake-0.4.0.gem#  检测 rake 是否有效$gem cleanup#  清除 所有包旧版本,保留最新版本$gem contents rake#  显示 rake 包中所包含的文件$gem dependency rails -v0.10.1#  列出 与 rails 相互依赖的包$gem environment#  查看 gem 的环境$$sudo gem -v#  查看 gem 版本(以管理员权限)$sudo gem install cocoa pods#  安装 CocoaPods(以管理员权限)$sudo gem install cocoapods#  安装 CocoaPods(以管理员权限)$sudo gem install cocoapods --pre#  安装 CocoaPods 至预览版(以管理员权限)$sudo gem install cocoapods -v0.39.0#  安装 CocoaPods 指定版本(以管理员权限)$sudo gem update cocoapods#  更新 CocoaPods 至最新版(以管理员权限)$sudo gem update cocoapods --pre#  更新 CocoaPods 至预览版(以管理员权限)$sudo gem uninstall cocoapods -v0.39.0#  移除 CocoaPods 指定版本(以管理员权限)

③ pod 指令库

$pod setup#  CocoaPods 将信息下载到~/.cocoapods/repos 目录下。如果安装 CocoaPods 时不执行此命令,在初次执行 pod intall 命令时,系统也会自动执行该指令$pod --version#  检查 CocoaPods 是否安装成功及其版本号$pod install#  安装 CocoaPods 的配置文件 Podfile

五、引用资料

说明:此处是列举了我安装CocoaPods 和写这篇文章时查询引用的文章,如有涉及到版权问题,请联系,我会删除的。

01-Rvm、Ruby及Cocoapods安装

02-RVM 和 Ruby的安装

03-iOS的库依赖管理工具CocoaPods

04-CocoaPods的安装以及遇到的坑

05-ios开发怎样卸载已经安装的cocoapod

06-配置CocoaPods前 - 本地安装好Ruby环境

07-iOS 学习笔记二【cocopods安装使用和安装过程中遇到的问题及解决办法】【20160725更新】

08-ruby学习及编译ruby缺少openssl问题解决

01-解决升级EI Capiton CocoaPods "pod: command not found"

02-curl: (35) Server aborted the SSL handshake

03-第一种 - Error running '__rvm_make -j 1'

04-第二种 - Error running '__rvm_make -j 1'

05-[!] Unable to add a source with url "xxxxxxxxxxxxx"

06-Error running 'requirements_osx_brew_update_system ruby-2.0.0-p643'

07-关于安装cocoapods遇到的一些坑(ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2)

08-Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1

六、后续更新

2016.12.15 问题更新

安装 CocoaPods 步骤指令问题

① 最初写的:

由于 OS X 系统的不同,此处的指令也是有些变化:OS X 10.11之前系统的安装 CocoaPods 指令: $ sudo geminstallcocoapodsOS X10.11以后系统的安装 CocoaPods 指令: $ sudo geminstall-n /usr/local/bincocoa pods

② 更改原因:

因为有朋友说在mac OS 10.11和mac OS 10.12环境中所用的指令不一样,当时写这篇文章的时候环境是mac OS 10.11,但是并没有做mac OS 10.12的环境,今天又做了一下测试,现在的环境是mac OS 10.12.1。

测试环境 mac OS 10.12.1.png

③ 测试结果:

----> 指令:

----> $ sudo gem install cocoa pods

----> 不需要密码

指令:$ sudo gem install cocoa pods 测试结果.png

----> 指令:

----> $ sudo gem install cocoapods

----> 需要密码

指令:$ sudo gem install cocoapods 测试结果.png

----> 指令:

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

----> 需要密码

指令:$ sudo gem install -n /usr/local/bin cocoa pods 测试结果.png

④ 测试结论:

三种结果都能安装 Cocoapods 成功,只不过安装更新的内容略有不同。

推荐使用:指令:$ sudo gem install cocoapods

报错信息板块尚未写完,后面有时间会继续完善!!!

如果有错误的信息,希望大家可以指出,进而及时修改,相互学习!!!

如有转载的,希望可以注明出处!!!

iOS之工具使用集锦

© 著作权归作者所有



作者:Dokki
链接:https://www.jianshu.com/p/059f3b910aae
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

猜你喜欢

转载自blog.csdn.net/sndongcheng/article/details/84642550
今日推荐