網(wǎng)上存在著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電腦系統(tǒng)的Ruby就可以了苟穆。而現(xiàn)在網(wǎng)上大部分的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
安裝完成后抄课,我們就開始使用吧!v谩跟磨!
學(xué)習(xí)更多:Using CocoaPods
- Creating a new Xcode project with CocoaPods.
- Open a terminal window, and $ cd into your project directory.
- Create a Podfile. This can be done by running $ pod init.
- 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