Qt Creator - Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild

C++XcodeMacosQtQt Creator

C++ Problem Overview


I just installed Qt 5.5 and am using Qt Creator for the first time on OS X. When I first installed Qt, it gave me an error message 'Xcode 5 not installed' which I thought was strange, (I have the Xcode 7 beta), but the install completed successfully anyways.

Now, when I start or open a project, I get the error:

>Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.

When I run /usr/bin/xcodebuild in Terminal, I get the following:

>xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

I'm not sure what Xcode has to do with Qt Creator, unless it has something to do with accessing libraries for cross-platform compatibility, but is there a way to fix this issue?

C++ Solutions


Solution 1 - C++

>= Xcode 8

In Xcode 8, as Bruce said, this happens when Qt tries to find xcrun when it should be looking for xcodebuild.

Open the file:

Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf

Replace:

isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null")))

With:

isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")))

~> Xcode 8

Before Xcode 8, this problem occurs when command line tools are installed after Xcode is installed. What happens is the Xcode-select developer directory gets pointed to /Library/Developer/CommandLineTools.

Point Xcode-select to the correct Xcode Developer directory with the command:

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

Confirm the license agreement with the command:

sudo xcodebuild -license

This will prompt you to read through the license agreement.

Enter agree to accept the terms.

Solution 2 - C++

If you change content of Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf then it will work only for Desktop kit, not for ex. simulator.

A better way is just to create symlink:

cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun

so you don't have to change .prf files for all targets.

Solution 3 - C++

This will do the trick:

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

Run this in your terminal.

Solution 4 - C++

For users of Xcode 8, there is another problem. See here for a temporary solution until Qt 5.7.1 is released:

https://forum.qt.io/topic/71119/project-error-xcode-not-set-up-properly

To summarise:

Open Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf in a text editor, and replace this:

isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))))

with this:

isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")))

Solution 5 - C++

If you build Qt from source with XCode 8.x, you have to change the "-find" argument in the file qt-everywhere-enterprise-src-5.7.0/qtbase/configure on line 551 so that it looks like:

if ! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then

Solution 6 - C++

Managed to solve it installing the full version of Xcode, agreeing to the terms, then using xcode-select --reset.

Basically the problem is that the xcode you're pointing at /Library/Developer/CommandLineTools doesn't allow you to accept the terms & conditions. So after the install & resetting the location, all should be OK

Solution 7 - C++

For me, the only way to work correctly is to commenting the lines about xcrun with the '#':

# Make sure Xcode is set up properly
#isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))): \
    #error("Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.")

At the file: Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf

Solution 8 - C++

Just to add a bit to a lot of old answers in the spirit of "This worked for me" I found that by launching Xcode, logging in to my developer account (just a free one) and then setting the Command tools in "Locations". I could get the

'sudo /usr/bin/xcodebuild -license agree'

to work. i.e. it launched an agree process in the command line and I agreed after careful reading of all 14 squillion pages of stuff.

I did not have to edit anything.

My system is Mojave 10.14.6 and Xcode 10.3 (10G8).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question123View Question on Stackoverflow
Solution 1 - C++123View Answer on Stackoverflow
Solution 2 - C++Rudolf RatusińskiView Answer on Stackoverflow
Solution 3 - C++ShndView Answer on Stackoverflow
Solution 4 - C++BruceView Answer on Stackoverflow
Solution 5 - C++remikzView Answer on Stackoverflow
Solution 6 - C++RamsesView Answer on Stackoverflow
Solution 7 - C++MarceloView Answer on Stackoverflow
Solution 8 - C++nerak99View Answer on Stackoverflow