Unreal Engine inaccurately reports "XCode is too old" when CommandLineTools installed

SUMMARY:
Unreal for Mac OS X, at startup, displays the error:
“Xcode installed on this Mac is too old to be used for Metal shader compilation. Falling back to runtime compiled text shaders, which are slower. Please update to latest version of xcode for best performance.”
…in cases where Xcode is at the newest version, but the “xcode-select” tool has selected Apple’s CommandLineTools package rather than Xcode.

A user can get into this state if when setting up their computer they install CommandLineTools, or the popular “Homebrew” utility, before they install Xcode. If this happens, Unreal will perpetually display a misleading error message at startup, and the user will likely not be able to figure out the cause of the error message on their own. In addition, the user will not get the benefit of Metal.

REPRO STEPS:
Install UE 4.18 and the newest XCode on a Macintosh. Ensure the Command Line Tools package is installed. I think you can do this by running xcode-select --install see here. Set the Command Line Tools package to be the standard command line tool provider by running
sudo xcode-select -s /Library/Developer/CommandLineTools
…in Terminal. This will simulate the state of having installed CommandLineTools before Xcode. You can see that you have a working compiler toolchain by typing cc
Now open Unreal Editor. You will see the “Xcode installed on this Mac is too old” dialog.
Close unreal editor and reset your command line tool provider by running
sudo xcode-select -r
Reopen unreal editor. The error will be gone.

CONTEXT:
Apple in recent years has distributed two choices for getting C compilers: XCode, a full GUI IDE, and “CommandLineTools”, a minimal package containing basic tools for UNIX style development. xcode-select is a tool Apple providers for specifying what compiler version that the command line utilities cc, xcrun etc use, in case the user has multiple versions of XCode installed. CommandLineTools is automatically installed if you install the popular UNIX-tool package managers “homebrew” or “MacPorts”.

The CommandLineTools package does not contain the OS X or iPhone SDKs, and therefore does not contain the metal command line tool. If I use xcode-select to select CommandLineTools, then run xcrun -sdk macosx metal, the metal compiler is not found. If I use xcode-select to select XCode, metal is again found.

HOW I EXPERIENCED THIS BUG:
When first setting up my laptop (last December), the first thing I did was install Homebrew. A couple months later, I installed XCode. When I installed Unreal 4.18.0 yesterday, I got the “Xcode is too old” error message. I upgraded XCode to the newest (9.1, 9B55) but still got the error. I checked my XCode version with xcode-select -p and saw that CommandLineTools was selected. I reset my XCode with xcode-select -r and the error message went away.

EXPECTED BEHAVIOR:
Because the case of CommandLineTools being selected and Metal therefore being absent is forseeable, Unreal should provide a helpful error message in this case and specifically recommend the correct fix (run sudo xcode-select -r in Terminal). Ways that Unreal could detect this include invoking xcrun -sdk macosx metal -v and detecting not-found; checking xcodebuild -version before blaming XCode’s version number; and checking xcode-select -p to detect a nonstandard xcode selection (although people using OS X betas often select unusual XCodes on purpose, anything other than /Applications/Xcode.app/Contents/Developer suggests a potential problem).

Hi mcclure111,

Thank you for letting us know about this issue. I was able to reproduce the inaccurate warning message, and have entered UE-52314 to have this investigated further.

Thanks for being detailed here with a workaround. I had bumped into this issue and it was slowing down my shader compiles so much on my mac. The workaround resolved my problems. I am using UE4.18.3 and XCode 9.2

running sudo xcode-select -r solved “Your XCode is too old” warning for me and also creating new c++ class files is now possible! thank you so much.
osx 10.13.4, XCode 9.3, UE 4.19.2

Thank you! I had same problem on UE4.20.3. I had recently installed Homebrew. This solved the “old version error” on UE4 startup.

Had the issue after installing OpenSSL for Codeworks (Android). That command in the terminal resolved it. Thanks!

Same problem, this line fix the problem, OS 10.14.1, Xcode 10.1, UE 4.20.

This still exists in 4.21 but it’s clearly expected behaviour and at worst a problem with homebrew. I ran into this while going through a Jenkins setup guide.

We could be proactive and add a button to the iOS project config panel to make it use the latest (or select a) version of XCode, as finding this page was pretty painful. Something similar already exists for the Android section.

Same problem here, this codeline fix the problem, OS 10.13.6, Xcode 10.1, UE 4.21.2 version.
Thank you! Your precise answer helped me a lot.

Why is that issue marked as fixed? Still happening in 4.22.3

Still exists in 4.21.2 and 4.22.3 with Xcode 10.3 (Current)
Removing command line tools for Xcode isn’t an option. They are needed for many other projects.

in my Unreal Engine 4.23.1 problem “Xcode was not detected on this Mac” although i have Xcode 10.1 on my HighSierra Mac
running sudo xcode-select -r does not help

in my Unreal Engine 4.23.1 problem “Xcode was not detected on this Mac” although i have Xcode 10.1 on my HighSierra Mac
running sudo xcode-select -r does not help

i did sudo xcode-select -p and renamed Xcode 10.1 into Xcode
Now is work

sudo xcode-select -r solved the problem

Unreal 4.23.1
Catalina 10.15.4