gem sources --remove https://rubygems.org/
//淘寶源已經(jīng)不可用
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/
此時(shí)可以更新
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
成功后會(huì)提示
1 gem installed
此時(shí)可以查找某一個(gè)庫
pod search afnetworking
但是會(huì)卡在
Setting up CocoaPods master repo
不要擔(dān)心
mac下 cmd+n 創(chuàng)建新窗口進(jìn)行查看
先進(jìn)到該目錄
cd ~/.cocoapods
然后查看大小
//默認(rèn)只有一個(gè)文件 repos
du -sh *
298M repos
新的china源應(yīng)該有600-700兆大小
慢慢等,這個(gè)下載拼網(wǎng)速與人品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 '替換為項(xiàng)目名' do
#NetWorking
pod 'Alamofire', '~> 4.7'
target '項(xiàng)目名Tests' do
inherit! :search_paths
# Pods for testing
end
target '項(xiàng)目名UITests' do
inherit! :search_paths
# Pods for testing
end
end