CocoaPods安裝和使用教程

安裝過程:html

xcode -> homebrew -> RVM -> Ruby -> CocoaPatsgit

1 安裝xcode github

2 homebrew 官方網站:http://brew.sh/index_zh-cn.htmlvim

3 Ruby xcode

$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
$ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org

4 安裝cocoapodsruby

1)$ sudo gem install cocoapods服務器

//sudo 爲獲取管理員權限因此須要輸入密碼網站

2)$ sudo gem update --systemspa

//若是提示gem版本太低須要升級gem.net

3)$ pod search afnetworking 

//afnetworking 爲第三方庫的名稱

//若是cocoapods支持

將會出現  :  /*

-> AFNetworking (2.3.1)

A delightful iOS and OS X networking framework.

pod 'AFNetworking', '~> 2.3.1’(這個語句是須要在編輯Podfile的時候輸入的命令,便是如何安裝下載相關類庫的指令)

- Homepage: https://github.com/AFNetworking/AFNetworking

- Source: https://github.com/AFNetworking/AFNetworking.git

- Versions: 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]

- Sub specs: - AFNetworking/Serialization (2.3.1) -

AFNetworking/Security (2.3.1) - AFNetworking/Reachability (2.3.1) -

AFNetworking/NSURLConnection (2.3.1) - AFNetworking/NSURLSession (2.3.1)

- AFNetworking/UIKit (2.3.1)

-> AFNetworking+AutoRetry (0.0.5)

Auto Retries for AFNetworking requests

pod 'AFNetworking+AutoRetry', '~> 0.0.5'

- Homepage: https://github.com/shaioz/AFNetworking-AutoRetry

- Source: https://github.com/shaioz/AFNetworking-AutoRetry.git

- Versions: 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1 [master repo]

*/

/*

若是沒有成功,提示:Setting up CocoaPods master repo
cocoapods 安裝有兩個步驟:A.cocoapods環境安裝 B.cocoapods主枝建立(至關於從cocoapods服務器上checkout一份到你的電腦)
7.移除cocoapods主支
pod repo remove master

8.修改cocoapods地址
pod repo add master https://gitcafe.com/akuandev/Specs.git
//其中https://gitcafe.com/akuandev/Specs.git 
也可還成http://git.oschina.net/akuandev/Specs.git

9.更新cocoapods主支
pod repo update

*/

10 $ cd (工程文件目錄)

11 $ vim Podfile

12 在podfile中寫入你想要的第三方庫

eg:pod 'JSONKit','~>1.5pre'  

//庫的名稱  庫的版本

13 退出編輯 並 保存:「esc」「:」 「wq」

14 安裝第三方庫 : $ pod install

15 退出全部工程文件 並 在工程中使用第三方庫 :$ from now on use '(工程名稱)'

相關文章
相關標籤/搜索