Mac Pro M2安裝使用Cocoapods
在新公司要做iOS開(kāi)發(fā),所以在新電腦上安裝Cocoapods
在升級(jí)gem,sudo gem update --system
,和安裝cocoapods
時(shí)都遇到如下的提示:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem
原因大概是:Apple已內(nèi)置安裝了ruby,不能修改
參考:
- While executing gem … (Gem::FilePermissionError)
the reason why you are getting that error is because Apple doesn’t allow you to install gems directly into the version of Ruby that came preinstalled on your Mac
其中的一個(gè)解決辦法就是,可通過(guò)安裝ruby版本管理器來(lái)解決,如chruby
或者RVM
安裝chruby
參考Install Ruby 3.1 · macOS
brew install ruby-install chruby
安裝后按提示,在.zshrc
中寫(xiě)入如下的內(nèi)容:
source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
source /opt/homebrew/opt/chruby/share/chruby/auto.sh
chruby ruby-3.2.2
注意chruby ruby-3.2.2
,這個(gè)地方的ruby版本,已你安裝的版本為準(zhǔn)
然后安裝Ruby,如下的代碼安裝并使用最新的ruby
ruby-install --latest ruby
安裝之前看下當(dāng)前系統(tǒng)的ruby的版本:
ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
SwitchHosts
在安裝過(guò)程中,可能會(huì)提示raw.githubusercontent.com
網(wǎng)站的內(nèi)容不能訪問(wèn),此時(shí)需要配置host,推薦安裝SwitchHosts
host配置如下:
185.199.110.133 raw.githubusercontent.com
或者參考:
- ineo6/hosts
配置一個(gè)遠(yuǎn)程的,自動(dòng)更新的host
然后可能需要重啟系統(tǒng)才生效。繼續(xù)執(zhí)行ruby-install --latest ruby
chruby
參考:
- postmodern/chruby
使用chruby
命令列出可用的ruby
使用chruby 3.2.2
,選擇3.2.2
的版本
cocoapods
參考官方文檔:
- WHAT IS COCOAPODS
安裝cocoapods
sudo gem install cocoapods
cocoapods鏡像
原始源地址為https://github.com/CocoaPods/Specs.git
參考CocoaPods 鏡像使用幫助
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
最后進(jìn)入自己的工程,在自己工程的podFile第一行加上:
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
ruby鏡像
移除現(xiàn)有的Ruby鏡像
gem sources --remove https://rubygems.org/
添加清華的鏡像,參考Ruby Gems 鏡像使用幫助
# 添加鏡像源并移除默認(rèn)源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
# 列出已有源
gem sources -l
# 應(yīng)該只有鏡像源一個(gè)
gem
gem相關(guān),可參考:
- RubyGems
查看gem版本:
gem -v
遇到的問(wèn)題
1.pod install
時(shí)提示HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
按網(wǎng)絡(luò)上的說(shuō)法解決:
git config --global http.version HTTP/1.1
2.git clone
時(shí)的各種出錯(cuò)
猜測(cè)是由于國(guó)內(nèi)的網(wǎng)絡(luò)環(huán)境造成的,所以可以給git配置代理
查看git代理:
git config --global --get http.proxy
git config --global --get https.proxy
設(shè)置git代理:
git config --global http.proxy "http://127.0.0.1:7890"
git config --global https.proxy "https://127.0.0.1:7890"
取消設(shè)置:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-645772.html
git config --global --unset http.proxy
git config --global --unset https.proxy
其他
可參考:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-645772.html
- m1 silicon macos 安裝 cocoapods
- CocoaPods 常見(jiàn)問(wèn)題
到了這里,關(guān)于Mac M2 Pro安裝使用Cocoapods的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!