(CocoaPods) - 20200512 CocoaPods 安裝與使用

閑著沒事(卡卡卡卡)重做系統(tǒng),也為了使用最新的 Xcode版本,更新到最新的系統(tǒng)版本

image.png

1 安裝 CocoaPods

1.1 ruby 更新(Catalina 的 ruby 是 2.6.3 版本,不需要更新,1.1 這一步可以跳過)
ruby 版本
// 查詢r(jià)uby版本號(hào)
$ ruby -v 

// 更新ruby
$ sudo gem update --system 
1.2 ruby 更換鏡像
// 查詢當(dāng)前鏡像
$ gem sources -l

// 移除默認(rèn)鏡像
$ gem sources --remove https://rubygems.org/

// 添加國(guó)內(nèi)鏡像
$ gem sources -a https://gems.ruby-china.com/

2 安裝 CocoaPods (我安裝的版本是 1.9.1)

// 安裝 CocoaPods 命令
$ sudo gem install cocoapods

// CocoaPods 安裝完成后,繼續(xù)輸入命令
$ pod setup
  • pod setup 很快就完成

CocoaPods 1.8 switches the CDN as the default spec repo source and comes with a few enhancements!

3 使用

3.1 官方 BLOG 說明,有個(gè)視頻很清楚
3.2 創(chuàng)建工程
// 添加 pod 支持,init
$ pod init

// 編輯 Podfile 之后,install
$ pod install
image.png
3.3 如果在 pod install 時(shí)提示
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/d/a/2/Alamofire/5.1.0/Alamofire.podspec.json Response: Couldn't connect to server
  • 修改hosts
// 修改hosts
$ sudo vim /etc/hosts

// 在下面添加一行,保存退出
199.232.4.133 raw.githubusercontent.com
修改 hosts
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容