前言
在開發(fā)過程中,會(huì)出現(xiàn)切換Cocoapods版本情況.
安裝Bundler
- 使用 gem list --local | grep cocoapods 查看安裝的Cocoaspod版本列表
gem list --local | grep cocoapods

Cocoapod 版本列表
- 通過pod --version 查看本地默認(rèn)Cocoaspod版本
pod --version

本地默認(rèn)Cocoaspod版本
- 通過執(zhí)行 gem install bundler 安裝Bundler 若無權(quán)限
gem install bundler
# 若無權(quán)限,則加上sudo
sudo gem install bundler

安裝Bundler
使用
- 入到項(xiàng)目所在的根目錄(即 Podfile 所在的目錄)
- 終端執(zhí)行 bundle init ,會(huì)生成Gemfile文件,Gemfile文件和Podfile文件非常相似。
bundle init
- 編寫Gemfile文件 (和Podfile文件編寫方式類似)
# frozen_string_literal: true
source "https://rubygems.org"
gem 'cocoapods','1.8.4'
- 如果未安裝指定版本的Cocoapod 需要執(zhí)行bundle install
bundle install
- 執(zhí)行 bundle exec pod install
bundle exec pod install