1.先升級Gem
? ? sudo gem update —system
sudo gem install cocoapods? //升級所有
2.切換cocoapods的數(shù)據(jù)源
? ? 【先刪除媒鼓,再添加蛇更,查看】
? ? gem sources --remove https://rubygems.org/
? ? gem sources -a? https://ruby.taobao.org/
? ? gem sources --add https://gems.ruby-china.org/
? ? gem sources -l
3.安裝cocoapods
? ? sudo gem install cocoapods
sudo gem install cocoapods -v 1.1.1
4.將Podspec文件托管地址從github切換到國內(nèi)的oschina
? ? 【先刪除,再添加维雇,再更新】
? ? pod repo remove master
? ? pod repo add master http://git.oschina.net/akuandev/Specs.git
? ? pod repo add master https://gitcafe.com/akuandev/Specs.git
? ? pod repo update
5.設(shè)置pod倉庫
? ? pod setup
6.測試
? ? 【如果有版本號,則說明已經(jīng)安裝成功】
? ? pod --version
7.利用cocoapods來安裝第三方框架
? ? 01 進(jìn)入要安裝框架的項(xiàng)目的.xcodeproj同級文件夾
cd ……
? ? 02 在該文件夾中新建一個(gè)文件Podfile
vim Podfile
? ? 03 在文件中告訴cocoapods需要安vim裝的框架信息
? ? ? ? a.該框架支持的平臺
? ? ? ? b.適用的iOS版本
? ? ? ? c.框架的名稱
? ? ? ? d.框架的版本
8.安裝
pod install --no-repo-update
pod update --no-repo-update
官網(wǎng)是這樣給推薦的:
在創(chuàng)建Podfile的時(shí)候晒他,用這種格式使用吱型,
platform :ios, '8.0'
#use_frameworks!個(gè)別需要用到它,比如reactiveCocoa
target 'MyApp' do
? pod 'AFNetworking', '~> 2.6'
? pod 'ORStackView', '~> 3.0'
? pod 'SwiftyJSON', '~> 2.3'
end
下面是另外一種寫法陨仅,
platform :ios, '8.0'
#use_frameworks!個(gè)別需要用到它津滞,比如reactiveCocoa
def pods
? pod 'AFNetworking', '~> 2.6'
? pod 'ORStackView', '~> 3.0'
? pod 'SwiftyJSON', '~> 2.3'
end
target 'MyApp' do
? pods
end
http://blog.csdn.net/fenglinyunshi/article/details/50518403
platform :ios, '8.0'
target 'TestOCWeiBo' do
? pod 'AFNetworking'
? pod 'MJExtension
? pod 'SDWebImage
? pod 'MJRefresh
end
## CocoaPods
- Podfile.lock文件
? ? - 最后一次更新Pods時(shí), 所有第三方框架的版本號
- 常用指令的區(qū)別
? ? - pod install
? ? ? ? - 會根據(jù)Podfile.lock文件中列舉的版本號來安裝第三方框架
? ? ? ? - 如果一開始Podfile.lock文件不存在, 就會按照Podfile文件列舉的版本號來安裝第三方框架
? ? ? ? - 安裝框架之前, 默認(rèn)會執(zhí)行pod repo update指令
? ? - pod update
? ? ? ? - 將所有第三方框架更新到最新版本, 并且創(chuàng)建一個(gè)新的Podfile.lock文件
? ? ? ? - 安裝框架之前, 默認(rèn)會執(zhí)行pod repo update指令
? ? - pod install --no-repo-update
? ? - pod update --no-repo-update
? ? - 安裝框架之前, 不會執(zhí)行pod repo update指令
相關(guān)鏈接: