前言
在开发过程中,会出现切换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