? ? 大多數(shù)iOS庫都支持CocoaPods绪励,用CocoaPods可以非常方便快捷的將效果庫加入到項(xiàng)目中忧陪。
如果你是一名iOS開發(fā)者蔗包,那么肯定會(huì)遇到需要使用CocoaPods的場(chǎng)景暮蹂。所以杏瞻,我們來學(xué)習(xí)一下CocoaPods,看看它是怎樣方便你進(jìn)行項(xiàng)目管理的嫡霞。
CocoaPods是什么:
CocoaPods是Objective-C項(xiàng)目的從屬管理器瓶埋,是庫管理工具,能方便引入上千個(gè)開源庫诊沪,讓你的項(xiàng)目更加靈活养筒。
CocoaPods官網(wǎng):http://cocoapods.org/
cocoapods安裝步驟
1、檢查ruby 版本:ruby -v
2端姚、如果ruby不是最新版本晕粪,將ruby更新到最新版本:gem update --system
3、驗(yàn)證你的Ruby鏡像是并且僅是taobao渐裸,可以用以下命令查看:gem sources -l
只有在終端中出現(xiàn)下面文字才表明你上面的命令是成功的:
*** CURRENT SOURCES ***
https://ruby.taobao.org/
4巫湘、可能存在錯(cuò)誤路徑是:
解決辦法:
4.1、移除錯(cuò)誤路徑:gem sources —remove? http://ruby.taobao.org
4.2昏鹃、移除錯(cuò)誤路徑:gem sources —remove? http://ruby.taobao.org/
插入正確鏡像路徑:gem sources -ahttps://ruby.taobao.org/
5尚氛、執(zhí)行安裝cocoapods命令:sudo gem install cocoapods
安裝正確時(shí),會(huì)輸出很多文件以及進(jìn)度條洞渤,如下:
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: cocoapods-core-1.0.1.gem (100%)
Successfully installed cocoapods-core-1.0.1
Fetching: claide-1.0.0.gem (100%)
Successfully installed claide-1.0.0
Fetching: cocoapods-deintegrate-1.0.0.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.0
Fetching: cocoapods-downloader-1.1.0.gem (100%)
Successfully installed cocoapods-downloader-1.1.0
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-stats-1.0.0.gem (100%)
Successfully installed cocoapods-stats-1.0.0
Fetching: cocoapods-trunk-1.0.0.gem (100%)
Successfully installed cocoapods-trunk-1.0.0
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.0
Fetching: molinillo-0.4.5.gem (100%)
Successfully installed molinillo-0.4.5
Fetching: xcodeproj-1.2.0.gem (100%)
Successfully installed xcodeproj-1.2.0
Fetching: fourflusher-0.3.2.gem (100%)
Successfully installed fourflusher-0.3.2
Fetching: cocoapods-1.0.1.gem (100%)
Successfully installed cocoapods-1.0.1
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for cocoapods-core-1.0.1
Installing ri documentation for cocoapods-core-1.0.1
Parsing documentation for claide-1.0.0
Installing ri documentation for claide-1.0.0
Parsing documentation for cocoapods-deintegrate-1.0.0
Installing ri documentation for cocoapods-deintegrate-1.0.0
Parsing documentation for cocoapods-downloader-1.1.0
Installing ri documentation for cocoapods-downloader-1.1.0
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-stats-1.0.0
Installing ri documentation for cocoapods-stats-1.0.0
Parsing documentation for cocoapods-trunk-1.0.0
Installing ri documentation for cocoapods-trunk-1.0.0
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.0
Parsing documentation for molinillo-0.4.5
Installing ri documentation for molinillo-0.4.5
Parsing documentation for xcodeproj-1.2.0
Installing ri documentation for xcodeproj-1.2.0
Parsing documentation for fourflusher-0.3.2
Installing ri documentation for fourflusher-0.3.2
Parsing documentation for cocoapods-1.0.1
Installing ri documentation for cocoapods-1.0.1
Parsing documentation for concurrent-ruby-1.0.2
Installing ri documentation for concurrent-ruby-1.0.2
15 gems installed
6怠褐、cocoapods安裝的默認(rèn)文件路徑:~/.cocoapods
7、檢查cocoapods是否安裝正確:在終端輸入pod search AFNetworking
如果cocoa pods安裝正確您宪,則會(huì)出現(xiàn)以下顯示:
AFNetworking (3.1.0)
A delightful iOS and OS X networking framework.
pod 'AFNetworking', '~> 3.1.0'
- Homepage: https://github.com/AFNetworking/AFNetworking
- Source:? https://github.com/AFNetworking/AFNetworking.git
- Versions: 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 3.0.0-beta.3,
3.0.0-beta.2, 3.0.0-beta.1, 2.6.3, 2.6.2, 2.6.1, 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]
- Subspecs:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/Security (3.1.0)
- AFNetworking/Reachability (3.1.0)
- AFNetworking/NSURLSession (3.1.0)
- AFNetworking/UIKit (3.1.0)