第三方框架
隱患
- 怕框架有BUG
- 怕框架停止更新
- 怕作者不及時更新
好處
- 簡單易用
- 更加穩(wěn)定
- 大大提高開發(fā)效率
注意
盡量選用更新頻率高喳资,維護人數(shù)多憎夷,星星數(shù)多的第三方框架
CocoaPods
替換源
//移除原有gem源
gem sources --remove https://rubygems.org/
//替換源
gem sources -a https://ruby.taobao.org/
https://gems.ruby-china.org/
//查看源
gem sources -l
更新gem
sudo gem update --system
安裝
sudo gem install cocoapods
出錯
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
解決方案:
sudo nvram boot-args="rootless=0"
sudo reboot
//重啟完成后
sudo gem install cocoapods -V
//如果仍然有錯
sudo gem install -n /usr/local/bin cocoapods
sudo gem install cocoapods --pre -n /usr/local/bin cocoa pods
初始化第三方庫信息
pod setup
Unable to add a source with urlhttps://github.com/CocoaPods/Specs.git
named master
.
sudo xcode-select -switch /Applications/Xcode.app
cd ~/.cocoapods/repos
git clone https://github.com/CocoaPods/Specs.git master
更新第三方庫信息
pod repo update
可以cd ~/.cocoapods目錄執(zhí)行du -sh *來查看進度
更換repo鏡像為國內服務器
//移除源服務器
pod repo remove master
//替換為國內源
pod repo add master https://gitcafe.com/akuandev/Specs.git
[!] To setup the master specs repo, please run `pod setup`.
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
//更新
pod repo update
搜索
pod search XXX
新建Podfile
cd /Users/knightyao/樣例/6\ model/CocoaPodsTest
vim Podfile
//編輯Podfile
platform :ios, '9.0'
use_frameworks!
target 'ilaw_swift' do
pod 'SDWebImage'
pod 'RESideMenu'
pod 'SVProgressHUD'
pod 'MJExtension'
pod 'MJRefresh'
pod 'FMDB'
pod 'ReactiveCocoa'
pod 'Alamofire'
end
安裝第三方庫
pod install
升級第三方框架
pod update
使用CocoaPods過程中出現(xiàn)問題
sudo gem update --system
sudo gem install cocoapods
pod setup