Aiki x Developer

git-issue

MacOS Catalina, Git: "unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!"

December 13th, 2019

git

Hiya!

I'm Arisa, a freelance Full-Stack & Frontend Developer living in Germany 🇩🇪.

Recently, I installed a new OS, Catalina.

But Catalina messed up a bit of my local environment...

Git command was not available somehow.

I remember when I updated to High Sierra, this also happened too.

It seems a common phenomena happens often that installing a new OS reset some commands' settings.

I figured out in the end and I'll show you what was the situation and the ways I tried out.

The Situation

  • Just newly installed Mac OS, Catalina

  • Tried to push on my Github repository as usual

  • Got an error message says, "git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!"

(MacBook Pro, 13-inch, Mid 2012, bought in 2012)

Full Error Logs

dyld: Symbol not found: _OBJC_IVAR_$_NSFont._fFlags Referenced from: /Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit in /Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly! git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

Option 1: Try to correct Xcode folder path

Since the error log says I need to correct Xcode folder into the right path, I guessed Xcode is still in my laptop as I can see in the Applications.

Based on the source in below, I tried this command.

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

Source: https://stackoverflow.com/questions/19647788/git-error-unable-to-locate-xcodebuild-after-a-fresh-os-x-mavericks-upgrade

But not working🤔

Option 2: For the case without Xcode is installed

This time, I assumed the case my laptop recognizes Xcode is not installed somehow although I did before.

$ sudo xcode-select --switch /Library/Developer/CommandLineTools/

Not working again.

Instead, I got this error log.

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools/'

Option 3(Part of the Solution): Install Xcode

At this point, I can't be 100% sure wether Xcode is correctly installed or not after updated the Mac OS.

But there are more options for me to try if I assume somehow Catalina made my laptop to see Xcode is not installed.

Then I installed Xcode.

$ xcode-select --install

It showed Xcode is installed with an installation pop-ups but still same error log in my terminal🤔

Option 4: Try to set the path to the Xcode folder using /usr/bin/xcode-select -switch

In the first error log, it says “You can set the path to the Xcode folder using /usr/bin/xcode-select -switch.”

Then I followed.

$ sudo xcode-select --switch /usr/bin/xcode-select

But got this response.

xcode-select: error: invalid developer directory '/usr/bin/xcode-select'

Option 5(Solution): Install "Command Line Tools" from a Xcode component

The last possibility I could think of was to install Command Line Tools from Xcode components.

Steps are in below👇

  1. Open X Code app → it showed me need the newest version to sign in to App Store.

  2. Sign in

  3. Install the newest Xcode

  4. Open → started to install components automatically.

  5. Open Xcode

  6. Open Developer Tool

  7. Got to More Developer tools → Login with Apple account

  8. Download the Command Line Tools

Source: https://discourse.brew.sh/t/xcode-select-error-invalid-developer-directory-library-developer-commandlinetools-failed-during-usr-bin-sudo-usr-bin-xcode-select-switch-library-developer-commandlinetools/693/12

But in my case, Xcode was saying, “This package is incompatible with this version of macOS.”

And “The package is trying to install content to the system volume. Contact the software manufacturer for assistance.”

Basically, this process showed me failed to install.

But when I check with the Terminal, it shows I have Git now😳

$ git --version git version 2.21.0 (Apple Git-122.2)

Pushing my repositories also works just fine.

After all, this was the solution in this case.

Summary

It was so long time ago I updated MacOS.

But I see a lot of people write they also have similar troubles when they update to the new OS.

Somehow, the Xcode disables or resets the Xcode component, Command Line Tools and changes its path after the new OS installation.

It's very incovenient for developers to spare our time extra for waiting to update the new OS and after waiting minimum an hour, then spending another time with Xcode path.

But I'd like to give a hope for the future that Xcode or Apple improves better💡

Ciao!