Cocoapods的安装
由于Mac系统更新,导致Cocoapods出现错误,所以不得不重新安装Cocoapods;
1.打开终端,查看源列表:
gem sources -l
2.将不需要的源地下移除掉,保证唯一:
gem sources --remove https://rubygems.org/
3.添加ruby-china源,2018.8更换成 https://gems.ruby-china.com
gem sources -a https://gems.ruby-china.com
4.安装cocoapods 需要输入密码 :
sudo gem install cocoapods
5.查看是否安装成功,成功的话会显示版本号
pod --version
6.将Github上的开源库https://github.com/CocoaPods/Specs.git托管的Podspec索引文件都下载到本地 ,花费时间比较久.
pod setup
7.切换到cd ~/.cocoapods/repos/master/
git clone https://github.com/CocoaPods/Specs.git //索引文件都下载到本地
8.如果pod search AFNetworking 命令报错如下:
[!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`
则删除原来的search_index.json文件
rm ~/Library/Caches/CocoaPods/search_index.json;
9.然后再次输入pod search AFNetworking进行搜索,pod search 命令会先查看有无search_index.json文件,如果不存在该文件,会自动根据master文件夹生成一个新的search_index.json文件,
10.在工程目录下,创建Podfile文件
vim Podfile 进入编辑模式
targer “Test” do
pod ‘AFNetworking’,’~>3.0’
end
按退出键ESC,输入:wq退出编辑模式
执行pod install
注意:Xcode选择的手机版本号
OK!又可以用cocoapods管理代码了;