需要从 Podfile 安装特定版本的 CocoaPods

Require specific version of CocoaPods to be installed form Podfile

在我们的项目中,当开发人员尝试执行 pod install[=16] 时,我们希望通过在 Podfile 中添加版本验证作为先决条件检查来确保所有开发人员都使用相同版本的 CocoaPods =] 或 pod 更新.

是否可以从 Podfile 中实现此目的?

为此,您需要创建一个 Gemfile,它类似于 RubyGems 的 Podfile,CocoaPods 作为其分发。有一个针对 CocoaPods here 执行此操作的指南。主要是您将创建一个 Gemfile,其中包含以下内容:

source 'https://rubygems.org'

gem 'cocoapods', '~> 0.38.2'

然后您可以使用bundle install安装您指定的版本。这将在所有开发人员的机器上安装相同的版本。之后,您将 运行 bundle exec pod install 以确保 pod install 是 运行 由您的 Gemfile 中指定的版本(如果用户有多个版本,情况可能并非如此安装的 CocoaPods)。