簡介
三方庫管理工具,很方便,開發(fā)自己的APP絕佳的輔助工具
安裝介紹
本人安裝時(shí)系統(tǒng)版本 10.12.6
安裝 CocoaPods之前,要先確保電腦本地是否有 Ruby環(huán)境,因?yàn)镃ocoaPods運(yùn)行于 Ruby之上,默認(rèn)情況下,Mac 是自帶了 Ruby 環(huán)境的,可以通過命令行 ruby -v查看當(dāng)前Ruby的版本。
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:~ jimy$ ruby -v ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin1
- 直接命令行安裝CocoaPods,會(huì)有如下錯(cuò)誤
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:~ jimy$ sudo gem install cocoapods ERROR: While executing gem ... (OpenSSL::SSL::SSLError) hostname "http://rubygems-china.oss.aliyuncs.com" does not match the server certificate
- 把鏡像源改成阿里云的
執(zhí)行命令:
- 查看當(dāng)前鏡像
gem sources -l
- 移除當(dāng)前鏡像
gem sources --remove https://rubygems.org/
- 替換成阿里云
zhouzhoujiedeMacBook-Pro:~ jimy$ gem sources -a http://rubygems- china.oss.aliyuncs.com
- 安裝,需要耐心等待
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:~ jimy$ sudo gem install cocoapods
簡單使用
- 正常創(chuàng)建IOS Swift APP ,名稱Test
- 打開終端,使用 cd 命令 進(jìn)入項(xiàng)目Test根目錄
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:~ jimy$ cd /Users/zhouzhoujie/Documents/project/Test
- 生成 Podfile(三方框架的注冊(cè)文件)
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:~ jimy$ pod init zhouzhoujiedeMacBook-Pro:Test jimy$ ls Des Podfile.lock Test.xcodeproj Desstatic Pods Test.xcworkspace Podfile Test
- 尋找三方框架,例如尋找"Moya"
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:Test jimy$ pod search Moya
- 找不到"Moya",你的CocoaPods的本地緩存三方庫列表需要更新了
執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:Test jimy$ pod update
- 修改Podfile,將"Moya"安裝進(jìn)入Test
Podfile修改如下
platform :ios, '9.0' use_frameworks! def shared_pods pod 'Moya', '3.2.0' end target ‘Test' do shared_pods end
7.將"Moya"安裝進(jìn)入Test項(xiàng)目
進(jìn)入項(xiàng)目根目錄,執(zhí)行命令:
zhouzhoujiedeMacBook-Pro:Test jimy$ pod install Analyzing dependencies Downloading dependencies Using Moya (8.0.5) Generating Pods project Integrating client project Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod >installed. [!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the >future, you should not use TextEdit for editing it. If you are not using TextEdit, you >should turn off smart quotes in your editor of choice. zhouzhoujiedeMacBook-Pro:Test jimy$
參考地址,Where 抄 come from
[地址] (http://blog.csdn.net/ylgwhyh/article/details/50542688)