第三方框架
隐患
- 怕框架有BUG
- 怕框架停止更新
- 怕作者不及时更新
好处
- 简单易用
- 更加稳定
- 大大提高开发效率
注意
尽量选用更新频率高,维护人数多,星星数多的第三方框架
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目录执行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过程中出现问题
sudo gem update --system
sudo gem install cocoapods
pod setup
网友评论