"pod init" 创建错误 "You need at least git version 1.8.5 to use CocoaPods"

"pod init" creates error that says "You need at least git version 1.8.5 to use CocoaPods"

我无法在我的系统中安装任何 pod。 因此,我从 Mac 中删除了 cocoapods,然后重新安装了它。 该过程成功但是当我 运行 命令 pod init 终端中出现以下错误:

`verify_minimum_git_version!': [!] You need at least git version 1.8.5 to use CocoaPods (Pod::Informative)
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:49:in `run'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'

我还检查了我的 Git 版本,它是 1.8.4,但我正在获取更新相同版本的任何解决方案。

首先使用命令删除系统中现有的git:-

使用命令"which git" 这会给你路径说“/usr/local/bin/git”,然后使用命令->$ sudo rm -rf /usr/local/bin/git

这将从您的系统中删除现有的 git 然后再重新安装git

$ brew install git

它可能会发出警告说 Warning: git 2.13.2 is already installed, it's just not linked. You can use `brew link git` to link this version.

然后 运行 下面提到的命令:-

$ sudo chown -R $(whoami) /usr/local/share/
$ sudo chown -R $(whoami) /usr/local/lib
$ brew link --overwrite --dry-run git

它可能会给你错误 Error: Could not symlink share/git-core/templates/description Target /usr/local/share/git-core/templates/description already exists. You may want to remove it: rm '/usr/local/share/git-core/templates/description'

强制 link 并覆盖所有冲突文件: brew link --overwrite git

列出所有将被删除的文件: brew link --overwrite --dry-运行 git

然后最后 运行 命令

$ brew link --overwrite git

这就是我更新 git 和 pod init 工作的方式。希望对您有所帮助:)

我在安装第二个 Xcode 后遇到了类似的问题。 结果 xcode-select -p

中没有指定 command line tools

已通过手动选择较新的 Xcode 版本修复

It needs to set your command line tool version, in your Xcode (Preferences).

如果您已付费给苹果开发者 account/id,您可以从 Apple Download Portal 下载最新的命令行工具。


这里是当前稳定版和测试版 Xcode 工具和支持命令行工具的下载链接。 (确保您使用 Apple 开发者帐户上的高级开发者帐户登录以访问这些链接)

Xcode 11

Xcode 10

在系统中安装最新的命令行工具后,从 Xcode 菜单中进行设置。

(Xcode Menu Items) Xcode ► Preferences ► Location ► Command Line Tool ► Select appropriate command line tool

按照下面的建议进行操作即可解决此问题:

Xcode 首选项 -> 位置 -> 选择命令行工具:select Xcode 8.3 或任何你想要的 select.

第一步:

第 2 步:

希望它能解决您的问题!!!

我在安装最新版本的 XCode 9.3 -

后遇到了这个答案

我正在尝试做一个 -

  • Pod 更新 [或 --version,或任何 pod 命令...]
  • 我试过 "brew install git" 就像最上面的答案一样,但是有各种各样关于无法访问 Cellar 的投诉,然后当我添加访问权限时,缺少 c 编译器..

Xcode 首选项中的位置中的命令行工具设置显示命令已安装最新的 9.3 行工具 "correctly",但在阅读以上答案后我决定使用 -[=12= 再次安装它]

xcode-select --install

下载/安装后,pod 再次开始工作,brew 仍然存在问题,这是一个高 sierra 问题。固定 - https://github.com/Homebrew/brew/issues/3285.

  1. 运行命令 $ brew install git

  2. 然后导航到您的项目文件夹并键入 pod init

这些步骤对我有用