1.CocoaPods的安裝及使用:
查看當前的源
gem sources -l
//等有反應以後再敲入如下命令,添加淘寶鏡像
只有在終端中出現下面文字才代表你上面的命令是成功的:
*** CURRENT SOURCES ***
這時候,你再次在終端中運行:
--verbose參數表示顯示指令的執行過程
sudo gem install cocoapods --verbose
//將 CocoaPods Specs repository複製到你電腦上~/.cocoapods目錄下,
它須要一點時間來完成,你等就是了
pod setup
若是安裝失敗 ~/.cocoapods 裏面是空的,就須要從新setup
命令以下:
pod repo remove master
pod setup
執行pod setup若是出現以下報錯
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)
則執行:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
若是Ruby環境不夠新,可能須要更新如下:
sudo gem update --system
查看版本:
pod --version
搜索:
pod search AFNetworking
生成Podfile文件
pod init
Podfile文件示例:
platform :ios, '6.0'
target 'iOSDevTemplate' do
pod 'AFNetworking' //不顯式指定依賴庫版本,表示每次都獲取最新版本
pod 'AFNetworking', ‘2.0’ //只使用2.0版本
pod 'AFNetworking', ‘>2.0′ //使用高於2.0的版本
pod 'AFNetworking', ‘>=2.0′ //使用大於或等於2.0的版本
pod 'AFNetworking', ‘<2.0′ //使用小於2.0的版本
pod 'AFNetworking', ‘<=2.0′ //使用小於或等於2.0的版本
pod 'AFNetworking', ‘~>0.1.2′ //使用大於等於0.1.2但小於0.2的版本,至關於>=0.1.2而且<0.2.0
pod ‘AFNetworking’, ‘~>0.1′ //使用大於等於0.1但小於1.0的版本
pod ‘AFNetworking’, ‘~>0′ //高於0的版本,寫這個限制和什麼都不寫是一個效果,都表示使用最新版本
end
下載開源庫:
pod install --no-repo-update --verbose
更新開源庫:
pod update --no-repo-update --verbose
更新本地索引庫
pod repo update --verbose