2021-03-29 cocoapods版本降级&使用bundle管理多版本cocoapods

一、安装指定版本cocoapods

安装指定版本

sudo gem install -n /usr/local/bin cocoapods --version 1.9.3

删除其他不要的版本
创建脚本 cocoapods install.sh 一键删除

#gem list |grep cocoapods

# cocoapods (1.10.1, 1.9.3, 1.8.4, 1.7.5, 1.7.0, 1.2.1)
# cocoapods-core (1.10.1, 1.9.3, 1.8.4, 1.7.5, 1.7.0, 1.2.1)
# cocoapods-deintegrate (1.0.4)
# cocoapods-downloader (1.4.0, 1.3.0)
# cocoapods-plugins (1.0.0)
# cocoapods-search (1.0.0)
# cocoapods-stats (1.1.0)
# cocoapods-trunk (1.5.0, 1.4.1)
# cocoapods-try (1.2.0, 1.1.0)

vesrions=(1.10.1 1.8.4 1.7.5 1.7.0 1.2.1)

for version in ${vesrions[*]}; do
    echo 密码 | sudo -S gem uninstall cocoapods -v $version
done

versions=(1.10.1 1.8.4 1.7.5 1.7.0 1.2.1)

for version in ${vesrions[*]}; do
    echo 密码 sudo -S gem uninstall cocoapods-core -v $version
done

gem list | grep cocoapods
# sudo gem install -n /usr/local/bin cocoapods --version 1.9.3


二、使用bunlder管理多版本cocoapods

使用bundle命令来指定pod版本

1、ruby gemfile 文件介绍

https://ruby-china.org/topics/26655

2、安装bunlder: gem install bundler

3、创建Gemfile: bundle init

默认文件内容为;

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

4、修改Gemfile文件内容为:

source "https://rubygems.org"

gem 'cocoapods', '1.5.3'  ##指定pod版本

gem 'cocoapods-links', '0.3.0'   #:git => '[email protected]:_ios/cocoapods-###指定git仓库地址

links.git', :tag=>'0.4.0' ###指定podlinks版本

5、使用指定版本的pod

bundle exec pod install --verbose --no-repo-update
bundle exec pod update --verbose --no-repo-update

6、查看本机安装的pod版本
gem list --local | grep cocoapods
cocoapods (1.7.3, 1.5.3, 1.2.1, 0.39.0)
cocoapods-core (1.7.3, 1.5.3, 1.2.1, 0.39.0)
cocoapods-deintegrate (1.0.4, 1.0.2)
cocoapods-downloader (1.2.2, 1.2.1, 0.9.3)
cocoapods-links (0.3.0)
cocoapods-mangle (1.0.1)
cocoapods-packager (1.5.0)
cocoapods-plugins (1.0.0, 0.4.2)
cocoapods-search (1.0.0, 0.1.0)
cocoapods-stats (1.0.0, 0.6.2)
cocoapods-trunk (1.3.1, 0.6.4)
cocoapods-try (1.1.0, 0.5.1)

7、安装pod
安装pod link工具: sudo gem install cocoapods-links
安装指定版本的pod: sudo gem install cocoapods -v 1.5.3

你可能感兴趣的:(2021-03-29 cocoapods版本降级&使用bundle管理多版本cocoapods)