1见秽、安裝Xcode
App Store下載即可
2、安裝Homebrew
方式 1:手動安裝 https://blog.csdn.net/icfhtg/article/details/107254950
方式 2:官網(wǎng)源安裝(有可能 443):
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
方式 3:國內(nèi)源安裝(??第一步直接選擇阿里源有問題讨盒,clone不下來)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2.1 Homebrew安裝上了解取,但是有些軟件無法安裝,可以考慮
使用阿里鏡像
替換 / 還原 brew.git 倉庫地址
# 替換成阿里巴巴的 brew.git 倉庫地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 還原為官方提供的 brew.git 倉庫地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
替換 / 還原 homebrew-core.git 倉庫地址
# 替換成阿里巴巴的 homebrew-core.git 倉庫地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 還原為官方提供的 homebrew-core.git 倉庫地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
3催植、安裝RVM
方式 1:官網(wǎng)源
curl -sSL https://get.rvm.io | bash -s stable
方式 2:若出現(xiàn)443 試試下面這個
curl -L [https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer](https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | bash -s stable
方式 3:若還是出現(xiàn)443 就只能試試下面這個了
a. 打開網(wǎng)站: https://www.ipaddress.com/
b. 查詢一下 raw.githubusercontent.com對應(yīng)的IP 地址
c. 將查詢到的IP添加到/ect/hosts
屁股后面肮蛹,舉個栗子:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
185.199.108.133 raw.githubusercontent.com
4、安裝ruby
4.1 列出已知的ruby版本
rvm list known
如果出現(xiàn)
command not found: rvm
可能是因為ram的shell配置沒有加載创南,在終端輸入:
source ~/.rvm/scripts/rvm
再輸入
type rvm | head -n 1
4.2 可以選擇現(xiàn)有的rvm版本來進(jìn)行安裝(以下就是是3.0.0安裝步驟)
4.2.1 安裝
rvm install 3.0.0
4.2.2 檢測是否安裝成功
ruby -v
4.2.3 環(huán)境配置
echo 'export PATH="/opt/homebrew/opt/ruby@3.0/bin:$PATH"' >> ~/.zshrc
4.2.4 立即生效
source ~/.zshrc
4.3 更換Ruby鏡像
4.3.1 移除
gem sources --remove https://rubygems.org/
4.3.2 添加(https://ruby.taobao.org/ 源已停止維護(hù))
gem sources -a https://gems.ruby-china.com/
4.3.2 是否更換成功
gem sources -l
5伦忠、安裝cocopods
5.1 安裝cocopods
// 普通方式1 (推薦)
sudo gem install cocoapods
// 普通方式2 (容易出現(xiàn) Could not find 'CFPropertyList' (>= 2.3.3, < 4.0) among 83 total gem(s)類似錯誤)
brew install cocoapods
// M1芯片
brew install cocoapods
5.2 配置pod(會比較慢,請耐心等待)
pod setup
//使用這句代替執(zhí)行效果更佳
git clone https://gitee.com/mirrors/CocoaPods-Specs.git ~/.cocoapods/repos/master
// 或者使用清華大學(xué)的(聽著就??皮哄哄的)
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/master
- 更新 gem
5.1 更新gem
sudo gem update --system
5.1 查看gem版本
pod --version
5.3 測試
pod search AFNetworking
5.4 錯誤
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'CFPropertyList' (>= 2.3.3, < 4.0) among 83 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/fengming/.rvm/gems/ruby-3.0.0:/Users/fengming/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0:/usr/local/Cellar/cocoapods/1.11.2_1/libexec', execute `gem env` for more information
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1449:in `block in activate_dependencies'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `activate_dependencies'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1420:in `activate'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1452:in `block in activate_dependencies'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `activate_dependencies'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1420:in `activate'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:304:in `block in activate_bin_path'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:303:in `synchronize'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
from /usr/local/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `<main>'
用下面這句重新安裝下就好了
sudo gem install cocoapods
[!] Unable to find a pod with name, author, summary, or description matching AFNetworking
將緩存刪掉重新搜索即可
rm ~/Library/Caches/CocoaPods/search_index.json