CocoaPods是一個負責管理iOS項目中第三方開源代碼的工具。javascript
2、安裝
因爲網上的教程基本都大同小異,但細節之處還不是很完善,因此藉機會在這裏補充下:
注:要使用CocoaPods,那就要下載安裝它,而下載安裝CocoaPods須要Ruby環境php
當前安裝環境爲Mac Pro 10.11.1。Mac OS自己自帶Ruby,但仍是更新一下保險,由於升級了系統以後,可能會出現一些意想不到的狀況,最好仍是更新一下Ruby。html
CYdediannao:~ lcy$ ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
CYdediannao:~ lcy$ gem sources - l *** CURRENT SOURCES *** http://ruby.taobao.org/ CYdediannao:~ lcy$ gem sources --add https://ruby.taobao.org/ --remove http://ruby.taobao.org/ https://ruby.taobao.org/ added to sources http://ruby.taobao.org/ removed from sources
CYdediannao:~ lcy$ sudo gem install rails
或者是 CYdediannao:~ lcy$ sudo gem update --system
CYdediannao:~ lcy$ sudo gem install cocoapods
CYdediannao:~ lcy$ sudo gem install cocoapods
Fetching: nap-1.0.0.gem (100%) Successfully installed nap-1.0.0 Fetching: molinillo-0.4.0.gem (100%) Successfully installed molinillo-0.4.0 Fetching: cocoapods-trunk-0.6.4.gem (100%) Successfully installed cocoapods-trunk-0.6.4 Fetching: cocoapods-try-0.5.1.gem (100%) Successfully installed cocoapods-try-0.5.1 Fetching: cocoapods-stats-0.6.2.gem (100%) Successfully installed cocoapods-stats-0.6.2 Fetching: cocoapods-search-0.1.0.gem (100%) Successfully installed cocoapods-search-0.1.0 Fetching: cocoapods-downloader-0.9.3.gem (100%) Successfully installed cocoapods-downloader-0.9.3 Fetching: xcodeproj-0.28.2.gem (100%) ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
CYdediannao:~ lcy$ sudo gem install -n /usr/local/bin cocoapods
Password:
Successfully installed xcodeproj-0.28.2 Fetching: cocoapods-core-0.39.0.gem (100%) Successfully installed cocoapods-core-0.39.0 Fetching: cocoapods-0.39.0.gem (100%) Successfully installed cocoapods-0.39.0 Parsing documentation for xcodeproj-0.28.2 Installing ri documentation for xcodeproj-0.28.2 Parsing documentation for cocoapods-core-0.39.0 Installing ri documentation for cocoapods-core-0.39.0 Parsing documentation for cocoapods-0.39.0 Installing ri documentation for cocoapods-0.39.0 3 gems installed
-> AFNetworking (2.6.0) A delightful iOS and OS X networking framework. pod 'AFNetworking', '~> 2.6.0' - Homepage: https://github.com/AFNetworking/AFNetworking - Source: https://github.com/AFNetworking/AFNetworking.git - Versions: 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] - 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-1 repo] - Subspecs: - AFNetworking/Serialization (2.6.0) - AFNetworking/Security (2.6.0) - AFNetworking/Reachability (2.6.0) - AFNetworking/NSURLConnection (2.6.0) - AFNetworking/NSURLSession (2.6.0) - AFNetworking/UIKit (2.6.0) -> 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] - 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1 [master-1 repo] -> AFNetworking+Ext (1.2.1) AFNetworking的封裝, 並提供一個 UIImageView+DYLoading cache in fileSystem+memory pod 'AFNetworking+Ext', '~> 1.2.1' - Homepage: https://github.com/junhaiyang/AFNetworkingExt - Source: https://github.com/junhaiyang/AFNetworkingExt.git - Versions: 1.2.1, 1.2, 1.1, 1.0, 0.5, 0.4, 0.3 [master repo] - 1.2.1, 1.2, 1.1, 1.0, 0.5, 0.4, 0.3 [master-1 repo] - Subspecs: - AFNetworking+Ext/Base (1.2.1) - AFNetworking+Ext/AFCustomRequestOperation (1.2.1) - AFNetworking+Ext/AFDownloadRequestOperation (1.2.1) - AFNetworking+Ext/AFTextResponseSerializer (1.2.1) - AFNetworking+Ext/example (1.2.1) - AFNetworking+Ext/UIKit (1.2.1) - AFNetworking+Ext/UIKit/UIImageView+DYLoading (1.2.1)