1.cocoaPods最新版本安裝
由于 Podfilede的配置是在cocoaPods上完成的,因此我們需要先配置最新版本的cocoaPods
1.1 打開終端丁逝,移除現(xiàn)有的Ruby默認(rèn)源
$gem sources --remove https://rubygems.org/
1.2 使用新的源
$gem sources -a https://ruby.taobao.org/
1.3 驗證新源是否替換成功
$gem sources -l
1.4 安裝CocoaPods
(1) $sudo gem install cocoapods 備注:蘋果系統(tǒng)升級 OS X EL Capitan 后改為 $sudo gem install -n /usr/local/bin cocoapods
(2) $pod setup
1.5 更新gem
$sudo gem update --system
2.配置Podfile
2.1 Xcode新建工程,并在終端用cd+空格指令到文件夾內(nèi)
cd cd /Users/a123/Desktop/wc_test
2.2 新建Podfile文件
vim Podfile
2.3 Podfile文件操作
文件創(chuàng)建好后,輸入“i”進(jìn)入編輯模式
platform :ios, '7.0'
target 'HouseNice' do
pod "AFNetworking","~>2.0"
end
輸入完摁esc退出編輯模式旋炒,接下來輸入“:wq”保存
!P来亍规脸!需要特別注意的是:iOS10后Podfile文件配置需在第二行以及末尾加上target 'HouseNice' do和end坯约,否則就會報錯!
2.4 最后一步
輸入pod install ,然后靜靜地等待吧莫鸭。配置完成后會提示
Analyzing dependencies
Downloading dependencies
Installing Masonry (1.0.1)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `1.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
123deMacBook-Pro:1 a123$
2.5 cocoapods安裝過程中的可能會遇到一些問題,比如有關(guān)rvm版本的升級闹丐,以及ruby源的一些問題,這些在下面的鏈接中都有非常詳細(xì)的解決辦法
源自”AZZ的博客“
http://blog.csdn.net/xieyupeng520/article/details/50443909
源自“—君少”
http://www.cnblogs.com/guanshenbao/p/5534578.html