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).