“pod init” creates error that says “You need at le

2019-03-09 00:08发布

问题:

I was not able to install any pod in my system. Hence, I removed cocoapods from my Mac and then reinstalled it. The process was successful but when I run the command pod init following error shows up in the terminal:

`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>'

I also checked my Git version which was 1.8.4 but I am getting any solution to update the same.

回答1:

Firstly remove the existing git in your system using commands:-

Use command "which git" that will give u the path say "/usr/local/bin/git", then use command->$ sudo rm -rf /usr/local/bin/git

This will remove existing git from your system Then reinstall git again

$ brew install git

It might issue a warning saying Warning: git 2.13.2 is already installed, it's just not linked. You can use `brew link git` to link this version.

Then run below mentioned command:-

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

It might give you error 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'

To force the link and overwrite all conflicting files: brew link --overwrite git

To list all files that would be deleted: brew link --overwrite --dry-run git

Then finally run command

$ brew link --overwrite git

This is how I updated my git and pod init worked. Hope you find it helpful :)



回答2:

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

You can download latest command line tool from Apple Download Portal, if you have paid apple developer account/id.


Here are current stable and beta Xcode Tools and supporting command line tool download links. (Ensure you're logged in using premium developer account on Apple Developer Account to access these links)

Xcode 10

  • Xcode 10.2 Beta
    - (Command Line Tool (Xcode 10.2 - Beta) - for macOS 10.14)

  • Xcode 10.1
    - (Command Line Tool (Xcode 10.1) - for macOS 10.14)
    - (Command Line Tool (Xcode 10.1) - for macOS 10.13)

  • Xcode 10
    - (Command Line Tool (Xcode 10) - for macOS 10.14)
    - (Command Line Tool (Xcode 10) - for macOS 10.13)

Xcode 9

  • Xcode 9.4.1
    - (Command Line Tool (Xcode 9.4.1) - for macOS 10.13)
  • Xcode 9.4
    - (Command Line Tool (Xcode 9.4) - for macOS 10.13)

  • Xcode 9.3.1

  • Xcode 9.3
    - (Command Line Tool (Xcode 9.3) - for macOS 10.13)

  • Xcode 9.2
    - (Command Line Tool (Xcode 9.2) - for macOS 10.13)
    - (Command Line Tool (Xcode 9.2) - for macOS 10.12)
  • Xcode 9.1
    - (Command Line Tool (Xcode 9.1) - for macOS 10.13)
    - (Command Line Tool (Xcode 9.1) - for macOS 10.12)
  • Xcode 9.0.1
    - (Command Line Tool (Xcode 9.0.1) - for macOS 10.13)
    - (Command Line Tool (Xcode 9.0.1) - for macOS 10.12)

  • Xcode 9.0
    - (Command Line Tool (Xcode 9) - for macOS 10.12)
    - (Command Line Tool (Xcode 9) - for macOS 10.13)

Once you've latest command line tool installed in your system, set it from Xcode Menu.

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



回答3:

I had a similar issue after installing a second Xcode. As a result there was no command line tools specified in xcode-select -p

Fixed by manually choosing newer Xcode version



回答4:

Do as suggested below and it will fix this issue:

Xcode Preferences -> Locations -> Selected the Command Lin Tools: select Xcode 8.3 or whatever you want to select.

Step-1:

Step-2:

Hope it will fix your issue!!!



回答5:

  1. Run the command $ brew install git

  2. Then navigate to your project folder and type pod init

These steps worked for me



回答6:

I came across this answer after installing latest version of XCode 9.3 -

I was trying to do a -

  • Pod Update [ or --version, or any pod command ...]
  • I tried to "brew install git" like in the top answer but there was all kinds of complaints about no access to Cellar, then when I added access, missing c compilers ..

The command line tools setting in Locations in Xcode Preferences showed command latest 9.3 line tools installed "correctly", but after reading the above answers I decided to install it again using -

xcode-select --install

After the download / install, pod started working again, was still having issues with brew which was a high sierra issue. fixed with - https://github.com/Homebrew/brew/issues/3285.