一、安装指定版本cocoapods
安装指定版本
sudo gem install -n /usr/local/bin cocoapods --version 1.9.3
gem sources --remove URL_HERE,
gem sources -l
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com/
sudo gem install cocoapods
删除其他不要的版本
有更加简单的方法:
gem list --local | grep cocoapods | awk '{print $1}' | xargs sudo gem uninstall
创建脚本uninstallPodAll.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
sudo 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
sudo 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 => 'git@gitlab.xxx.xxxx.com:_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