
I'm not positive that those two things are related, but you can see above that the macOS SDK that xcodebuild is looking for is MacOSX12.3.sdk. In my case, Xcode updated to v14.1 and my Mac is running macOS 12.6. Xcode-select: Failed to locate 'git', requesting installation of command line developer tools.
#Mac install xcode from command line code#
Git: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/atform/Developer/SDKs/MacOSX12.3.sdk -find git 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory) Git: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/atform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory) Xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/atform/Developer/SDKs/MacOSX12.3.sdk" cannot be located. The error I was seeing relating to the git binary was: 16:33:18.828 xcodebuild Writing error result bundle to /var/folders/mc/tm26v4sd0pv1hncprqdff72h0000gn/T/ResultBundle_16-33-0018.xcresult Which copies the older "MacOSX12" SDK into the Xcode 14 folders and seems to make everyone happy. Tl dr the solution is to run sudo cp -R /Library/Developer/CommandLineTools/SDKs/MacOSX12* /Applications/Xcode.app/Contents/Developer/Platforms/atform/Developer/SDKs/

I had this same problem, but none of the solutions above worked for me. Keep in mind that the Xcode tools when opening Xcode after further updates will need to be updated, but in my experience this should NOT affect the CLI tools. It seems the issue is not related to the architecture of the mac (M1 or Intel) or the Xcode version! Keep in mind, tools for the platforms you chose will be downloaded in the background, which might take a bit. Close and re-open your Terminal and try your CLI tools again.

Choose as few as possible as these take hard disk space!

Then you are told that you need to install additional tools, in my case clang. Xcode-select: Failed to locate 'clang', requesting installation of command line developer tools. If you use command line tools like Homebrew, you might have received the following error (the part below is just an excerpt of it): clang: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/atform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)
#Mac install xcode from command line update#
This issue happened on my MacBook Air M1 machine after update macOS Monterey 12.6 released recently and installing Xcode CLI tools version 14.0.
