[iOS]Cocoapods安装及安装问题解决, 使用Cocoa
今天把Cocoapods安装的详细过程跟大家分享一下, 安装的过程中出现的问题以及问题的解决办法也记录了一下, 欢迎阅读, 希望能帮到大家.

检查当前的pod版本, 如果Mac重来没安装过pod, 则会显示如下结果.
$ pod --version

查看当前路径,显示结果为如下图:
$ gem source -l

https://rubygem.org是国外的, 国内有"墙"我们通常用不了.😂国内淘宝为我们提供了可用路径.因此我们还要更改路径.
第一步先移除:
$ gem source -r

第二步添加路径:
$ gem source -a https://ruby.taobao.org/

添加路径之后, 安装cocoapods
$ gem install cocoa pods

如果出现如下结果:
ERROR:While executing gem...(Gem::FilePermissError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory

这时你就需要执行如下命令, 进行安装.
$ sudo gem install cocoa pods

恭喜你, 又掉坑了.
ERROR:Could not find a valid gem 'cocoapods' (>= 0) in any repository

这个错误的原因在于我们的ruby版本过低, 需要更新ruby版本至2.2.4以上
于是我们开始了升级之路:
$ -L get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm install 2.3





再次安装cocoapods
$ sudo gem install cocoa pods


cocoa pods 初始化:
$ pod setup

初始化成功后, 我们就可以正常使用了.

写的比较匆忙, 后续补上. 嘻嘻☺️.见谅见谅.
(2016-10-13)检查ruby, 表示淘宝的ruby仍在使用.
$ gem source -l

更新:
使用Cocoapods导入第三方库:
cocoapods的使用, 能让我们不需要去网站下载库文件导入工程, 仅需几行命令就能够将你想使用的第三方库导入到你的工程中, 并且不论是swift语言还是OC语言均可使用,这对很多人来说, 是非常实用的.
1 . 在安装cocoapods 成功的基础上, 打开你的工程文件.并将pod初始化.
$ cd yourProjectPath
$ pod init
2 .打开podFile文件, 在文件中写入你想导入的第三方库.使用( pod + '第三方库名')
$ open -a xcode podfile
例如:

3 . 将第三方库导入工程中.
$ pod install --verbose --no-repo-update
4 . 更新成功后, 将工程关闭, 打开.xcworkspace文件, 就会在pods目录下, 看到你所导入的第三方库.

PS:使用OC语言时, 如果你不确定你所导入的第三方库名,或者是库的版本, 你可以使用如下命令查询:
例:AFNetworking
$ pod search afnetworking
查询结果会是 终端把所有的AFNetworking的版本都列举出来, 你可以选择你想要使用的版本, 在podfile里面进行相应添加.