前言
在開發過程中,會出現切換Cocoapods版本情況.
安裝Bundler
- 使用 gem list --local | grep cocoapods 查看安裝的Cocoaspod版本列表
gem list --local | grep cocoapods
Cocoapod 版本列表
- 通過pod --version 查看本地默認Cocoaspod版本
pod --version
本地默認Cocoaspod版本
- 通過執行 gem install bundler 安裝Bundler 若無權限
gem install bundler
# 若無權限,則加上sudo
sudo gem install bundler
安裝Bundler
使用
- 入到項目所在的根目錄(即 Podfile 所在的目錄)
- 終端執行 bundle init ,會生成Gemfile文件,Gemfile文件和Podfile文件非常相似。
bundle init
- 編寫Gemfile文件 (和Podfile文件編寫方式類似)
# frozen_string_literal: true
source "https://rubygems.org"
gem 'cocoapods','1.8.4'
- 如果未安裝指定版本的Cocoapod 需要執行bundle install
bundle install
- 執行 bundle exec pod install
bundle exec pod install