安裝
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l
sudo gem install cocoapods
pod setup //初始化(下載幾十M很慢)
使用鏡像索引
pod repo remove master
pod repo add master https://gitcafe.com/akuandev/Specs.git
pod repo update
使用步驟
創建或打開Xcode項目
命令行cd到項目目錄
使用pod init 創建Podfile
修改Podfile
pod install
打開pod創建的xcworkspace
Podfile
podspec源
source 'https://git.coding.net/lee8001/linjiahaoyi.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0' 兼容iOS版本
use_frameworks! 使用動態的連接庫
inhibit_all_warning! 消除所有的pod庫警告
target ‘PodTest’ do ?給PodTest項目使用pod庫
? ? ?pod 'AFNetworking', '~>3.0'
end
命令
pod install 安裝Podfile.lock中鎖定的版本的pods
pod update 會更新到最新版本或Podfile中指定版本
使用pod update podName來更新指定pod版本
pod install --verbose --no-repo-update 不更新repo安裝
注
use_frameworks! ?swift項目必須開啟該選項,因為swift項目不支持靜態庫
podspec和私有pods
創建
cd 到項目目錄
pod spec create MyFramework
Podfile
target 'PodTest' do
pod 'MyFramework', :git => 'https://github.com/hefeijinbo/MyFramework.git'
pod 'MyFramework', :path => '路徑'
end