gem sources --remove https://rubygems.org/
//淘宝源已经不可用
gem sources -a https://ruby.taobao.org/
//新的china源
gem sources -a https://gems.ruby-china.com/
查看源
gem source -l
输出
*** CURRENT SOURCES ***
https://ruby.taobao.org/
此时可以更新
sudo gem update -n /usr/local/bin —system
若提示
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems
则不用更新 试试安装命令
sudo gem install -n /usr/local/bin/ cocoapods
成功后会提示
1 gem installed
此时可以查找某一个库
pod search afnetworking
但是会卡在
Setting up CocoaPods master repo
不要担心
mac下 cmd+n 创建新窗口进行查看
先进到该目录
cd ~/.cocoapods
然后查看大小
//默认只有一个文件 repos
du -sh *
298M repos
新的china源应该有600-700兆大小
慢慢等,这个下载拼网速与人品O(∩_∩)O哈哈~
如果提示
[!] Unable to find a pod with name, author, summary, or description matching 'AFNetworking'
则删除
rm ~/Library/Caches/CocoaPods/search_index.json
若下载好后直接搜索就可以了
pod search AFNetworking
新的podfile 编辑方式
platform :ios, '9.0'
target 'cocoapodsTest' do
pod 'AFNetworking', '~> 3.1.0'
end
Swift4.0的 Podfile编辑方式
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '替换为项目名' do
#NetWorking
pod 'Alamofire', '~> 4.7'
target '项目名Tests' do
inherit! :search_paths
# Pods for testing
end
target '项目名UITests' do
inherit! :search_paths
# Pods for testing
end
end