cocoapods执行命令行报错: You need at least git version 1.8.5 to use CocoaPods

今天使用cocoapods的 pod init 命令创建一个Podfile 文件时报错:

/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/command.rb:128:inverify_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.0/lib/cocoapods/command.rb:49:inrun’

from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/bin/pod:55:in'

from /usr/local/bin/pod:22:inload’

from /usr/local/bin/pod:22:in `’

我的cocoapods版本是 1.2.0;

这个问题可能是由于没有链接到 xcode,或者链接到的xcode版本过低。 前几天刚安装了一个 xcode8.3.3,我把新安装的xcode放到了Applications(应用程序)下,名字改成了xcode8.3.3; 导致pod 按原来的链接路径找不到xcode相应的目录;

解决办法:

方法1. 将新装的Xcode8.3.3 的名字修改为原来版本Xcode的名字;

方法2. 修改链接Xcode路径,命令是:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

(sudo xcode-select -switch /Xcode应用所在的文件路径/Contents/Developer)

你可能感兴趣的:(cocoapods执行命令行报错: You need at least git version 1.8.5 to use CocoaPods)