│ Ruby 版本 │ rbenv 或 rvm │ rbenv local 3.2.0 │
├────────────────┼──────────────┼─────────────────────────┤
│ CocoaPods 版本 │ Bundler │ bundle exec pod install │
└────────────────┴──────────────┴─────────────────────────┘
推荐你这样搞(一劳永逸)
1. 用 rbenv 管理 Ruby 版本
brew install rbenv
rbenv install 3.2.0
rbenv global 3.2.0
2. 用 Bundler 锁定 CocoaPods 版本
在你的 iOS 项目根目录:
gem install bundler
bundle init
编辑生成的 Gemfile:
source "https://rubygems.org"
gem "cocoapods", "~> 1.15"
然后:
bundle install
以后每次装 Pod 都用:
bundle exec pod install
这样做的好处:Gemfile.lock 会提交到 Git,团队所有人、所有分支用的 CocoaPods 版本完全一致,切分支再也不会因为版本不对要重新 install 了。