1敷待、項目跟目錄下建立Podfile文件格式如:
platform :ios, '7.0'
target 'FSPodDemo' do
pod 'MBProgressHUD', '~> 0.8'
end
2、終端 進入根目錄 執(zhí)行命令
pod install
如果提示Unable to find a specification for xxxxx
的問題則執(zhí)行下邊命令
pod install --verbose --no-repo-update
cocoapods安裝好后repo換源
1.pod repo
然后會出現(xiàn)以下內(nèi)容榜揖,如下是我已經(jīng)換了之后的抗蠢,而你的URL還是github的
master
Type: git (master)
Path: /Users/Mingo/.cocoapods/repos/master
網(wǎng)上給出了一個鋪天蓋地的方法思劳,,使用如下方法換掉repo的源:
pod repo remove master
pod repo add master https://git.coding.net/CocoaPods/Specs.git
pod repo update
然而呀潜叛,,威兜,,我試了好多次結(jié)果是:
[!] To setup the master specs repo, please run pod setup
.
最后繼續(xù)查找牡属,找到了如下的,方法:
執(zhí)行:
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
過來許久以后逮栅,
有如圖就正常了
最后切記要:
pod repo update
![image](http://upload-images.jianshu.io/upload_images/1513478-0511adcab756ba41.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
顯示上圖:說明安裝成功。
這時候在 pod repo 就是和開始的地方一樣了措伐。。
這樣之后侥加,,相信我們的pod install 和 pod update 等等都有快速好多了担败。
CocoaPods 托管在 GitHub 上即使翻墻速度還是太慢了,在Coding.net中發(fā)現(xiàn)一個國內(nèi)鏡像提前,15分鐘和官方同步一次。
使用方法:
pod repo remove master
pod repo add master https://git.coding.net/jasper/CocoaPods.git
pod repo update
pod setup
切回官方源
pod repo remove master
pod repo add master https://github.com/CocoaPods/Specs.git
pod repo update
pod setup
國內(nèi)Specs
清華大學鏡像
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
上海大學鏡像
https://mirrors.shu.edu.cn/CocoaPods (僅HTTP/HTTPS訪問宙搬,不支持git拉取)
https://mirrors.shu.edu.cn/mgit/Specs (僅git訪問)
https://git.shuosc.org/CocoaPods/Specs (均支持)
COCOAPODS SPECS 中國區(qū)鏡像表項
git://cocoapodscn.com/Specs.git
使用方法
對于舊版的 CocoaPods 可以使用如下方法使用國內(nèi)的的鏡像(以清華的鏡像為例):
pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
pod repo update
1
2
3
新版的 CocoaPods 不允許用pod repo add直接添加master庫了勇垛,但是依然可以:
cd ~/.cocoapods/repos
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
最后進入自己的工程,在自己工程的podFile第一行加上:
source ‘https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git’
重置為官方上游
cd ~/.cocoapods/repos
pod repo remove master
git clone https://github.com/CocoaPods/Specs master
最后進入自己的工程闲孤,在自己工程的podFile第一行加上
sources 'https://github.com/CocoaPods/Specs'