Xcode version must be specified to use an Apple CROSSTOOL

For me it was a licensing issue for xcodebuild. After running bazel clean --expunge I've tried to run again bazel and I've got the instruction to run sudo xcodebuild -license. I have executed, accepted the license terms, run again bazel clean --expunge and everything has started to work again. Hopefully it solves some of the cases.


Had the same problem, and since I am using a beta version of XCode, I had to find the installation in /Downloads/Xcode-beta.app instead.

Incidentally, the solution for me was to open XCode, go to Preferences, and select the Locations tab. The Command Line Tools drop-down was blank, and I had to press it and select a version (Xcode 9.0 in my case). I then ran bazel clean --expunge and repeated the build process without getting the error. Hope this helps someone.


bazel clean --expunge 
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
bazel clean --expunge 
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

It looks like xcode_configure isn't properly identifying that you have xcode installed. This can sometimes happen if you install xcode but have not yet fully opened it (it may ask you to agree to Terms and Conditions before being fully functional). If this is the problem, you'll need to bazel clean --expunge again after that...

If this doesn't help, you can get some debug information to identify what's gone wrong, by invoking (after a failed build):

cat $(bazel info output_base)/external/local_config_xcode/BUILD

This should contain some comments pertaining to failures in finding your installed xcodes.