安裝CocoaPods
>>方法一 ?(最簡潔)
新建一個項(xiàng)目:項(xiàng)目名自定
>>方法二
->>下載CocoaPods地址<<-? [方便快捷? 直接在CocoaPods運(yùn)行demo?]
打開Xcode 運(yùn)行demo? 然后運(yùn)行 下載好的 CocoaPods.app ?->> 如下:
>>方法三
1.打開終端輸入ruby -v(確實(shí)安裝了,如果這個版本接下來工作失敗了,就更新下ruby)b更新ruby )
示例:
ritekiMac-mini:PodTest?lucky$?ruby?-v
ruby?1.8.7?(2012-02-08?patchlevel?358)?[universal-darwin12.0]
ritekiMac-mini:PodTest?lucky$
2.終端輸入如下命令(把Ruby鏡像指向taobao毕骡,避免被墻,你懂得)
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l(用來檢查使用替換鏡像位置成功)
示例:
ritekiMac-mini:~?lucky$?gem?sources?--removehttps://rubygems.org/
https://rubygems.org/?removed?from?sources
ritekiMac-mini:~?lucky$?gem?sources?-ahttps://ruby.taobao.org/
https://ruby.taobao.org/?added?to?sources
ritekiMac-mini:~?lucky$?gem?sources?-l
***?CURRENTSOURCES***
3.下載安裝CocoaPods
終端輸入:sudo gem install cocoa pods
這個地方很坑未巫,之前安裝cocoapods一直是沒有這個問題的,這里提示Ruby版本要大于或等于2.2.2
于是查看ruby版本
$ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
果然這里就要升級Ruby版本啦
查看目前的所有ruby版本:
$rvm list known
如果提示command not found 請先安裝rvm
$curl -L get.rvm.io | bash -s stable
如果出現(xiàn)錯誤:可按照下面的鏈接進(jìn)行一步步操作:
CocoaPods 安裝詳解 - http://blog.csdn.net/u012960049/article/details/52275272
示例:
1.ritekiMac-mini:~?lucky$?sudo?gem?install?cocoapods
2.Successfully installed cocoapods-1.0.1
3.Parsing documentation for cocoapods-1.0.1
4.1 gem installed
4.使用CocoaPods
a新建一個項(xiàng)目劈伴,名字PodTest
b終端中握爷,cd到項(xiàng)目總目錄(注意:包含PodTest文件夾、PodTest.xcodeproj饼拍、PodTestTest的那個總目錄)
示例:
cd?/Users/lucky/Desktop/PodTest
5.建立Podfile(配置文件)
接著下一步,終端輸入vim Podfile
示例:
platform :ios, '9.0'
target 'PodTest' do
pod 'MBProgressHUD', '~> 0.9.2'
end
6.確定終端cd到項(xiàng)目總目錄漓柑,然后輸入pod install,等待一會辆布,大約3分鐘。
示例:
bogon:PodTest xuweibin$ pod install
Analyzing dependencies
Downloading dependencies
Installing MBProgressHUD (0.9.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `PodTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
終端輸入
*******************************************************************************
platform :ios, '9.0'
target 'E-IThome' do// E-IThome文件名
pod 'EaseMobSDK', :git => 'https://github.com/easemob/sdk-ios-cocoapods.git'
pod 'JSONModel'
pod "AFNetworking", "~> 3.0"
pod 'BmobSDK'
pod 'YYText'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'BaiduMapKit' #百度地圖SDK
end
*******************************************************************************