最官方的cocoapods的安装方法 强烈推荐

网上存在着cocoapods安装的各种教程,今天我们来一起看一下官方的安装文档是怎样说的。

Installation(安装)

CocoaPods is built with Ruby and it will be installable with the default Ruby available on macOS.
 You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on macOS unless you know what you're doing.

Using the default Ruby install will require you to use sudo when installing gems. 
(This is only an issue for the duration of the gem installation, though.)

上面这段话的意思建议我们使用Mac电脑系统的Ruby就可以了。而现在网上大部分的cocoapods的安装教程都是让我们更换我们的Ruby源

$ sudo gem install cocoapods
$ gem install cocoapods --user-install

$ gem which cocoapods
/Users/eloy/.gem/ruby/2.0.0/gems/cocoapods-0.29.0/lib/cocoapods.rb
$ /Users/eloy/.gem/ruby/2.0.0/bin/pod install
$ pod --version

Updating CocoaPods(升级)

To update CocoaPods you simply install the gem again

$ [sudo] gem install cocoapods

Or for a pre-release version

$ [sudo] gem install cocoapods --pre

安装完成后,我们就开始使用吧!!!

学习更多:Using CocoaPods

  1. Creating a new Xcode project with CocoaPods.
  2. Open a terminal window, and $ cd into your project directory.
  3. Create a Podfile. This can be done by running $ pod init.
  4. Open your Podfile. The first line should specify the platform and version supported.

问题:我在安装的时候遇到一个问题:

Snip20170808_2.png

解决办法:

Snip20170808_3.png
Snip20170808_4.png

清了一下cocoapods本地的搜索索引缓存就行了。
rm ~/Library/Caches/CocoaPods/search_index.json
pod search AFNetworking

你可能感兴趣的:(最官方的cocoapods的安装方法 强烈推荐)