一、安裝rvm(ruby version manager)和檢查更新ruby
- 安裝rvm
- 命令
$ rvm -v
- 已安裝
$ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
- 未安裝
$ rvm -v
-bash: rvm: command not found
//$ curl -sSL https://get.rvm.io | bash -s stable (參考 https://rvm.io)
$ curl -L https://get.rvm.io|bash -s stable
$ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
- 開(kāi)啟rvm
source /Users/username/.rvm/scripts/rvm
- Mac自帶ruby,檢查ruby環(huán)境,現(xiàn)在(2019/8/31)要求ruby環(huán)境at least 2.4.4,我的2.3.7
- rvm查看ruby版本:
$ rvm list known
- 更新命令:
(最新版本2.7.0)
$ rvm install 2.7.0
然后根據(jù)提示按:回車(chē)-回車(chē)-輸入密碼
刻炒,等待即可
二蝌矛、RubyGems(參考:https://gems.ruby-china.com)
- 檢查更新RubyGems環(huán)境
- 檢查
$ gem -v //建議2.6.x以上,我的2.5.2.3
- 更新
$ sudo gem update --system
- 查看替換RubyGems源
- 查看
$ gem sources -l
https://rubygems.org/
- 替換
$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
三碎罚、安裝cocoapods和使用
- 安裝coacoPods
$ sudo gem install -n /usr/local/bin cocoapods
$ git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
-
Mac M1出現(xiàn)的問(wèn)題
截屏2021-05-07 下午4.06.12.png
參考 issues
https://github.com/CocoaPods/CocoaPods/issues/10220
- 使用:
- 新建Xcode項(xiàng)目CocoaPodsTest
- 進(jìn)入項(xiàng)目根目錄CocoaPodsTest
- 創(chuàng)建Podfile文件
pod init
- Podfile配置
vim Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform:ios, '8.0'
target 'CocoaPodsTest' do
pod 'AFNetworking' '~>3.0'
end
- 安裝
pod install