Qt Creator - Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild
Solution 1
>= 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
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
This will do the trick:
#sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Run this in your terminal.
Solution 4
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
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
Comments
-
123 over 3 years
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?
-
Mohammed Rafeeq almost 8 yearsI got the error xcode-select: error: invalid developer directory '/Applications/Xcode.app/Contents/Developer'
-
Violet Giraffe over 7 yearsDoesn't work for me with Xcode 8. I have accepted the license via these instructions and still get the same error.
-
Libor B. over 7 yearsThanks, with XCode 8 after editing default_pre.prf it works !
-
tjeden over 7 yearsI prefer this version, so it looks less messy than editing cfg files.
-
mrAlmond over 7 yearsThis causes problems later when xcrun is invoked with parameters not supported by xcodebuild (missing parameter -f).
-
ALoopingIcon over 7 yearsIt seems a qt issue. So I consider more dangerous adding a lasting sym link inside xcode distrib than changing a qt conf file that will be replaced by Qt 5.7.1
-
DLRdave over 7 yearsFor the Xcode>=8 segment, if you are building Qt from a source tree, you also need to patch the
configure
file similarly. The commit which fixes this issue in Qt is codereview.qt-project.org/gitweb?p=qt/… -
yogodoshi over 7 yearsFor those wondering where is the installation folder: it will depend on your package manager's settings: /usr/local/Cellar/qt55 for Homebrew, /opt/local/libexec/qt5(-mac) for macports.
-
Chchwy over 7 yearsDon't do this, it mess up my iphone app project.
-
BuvinJ over 7 yearsI upvoted this too soon and got it locked in... I ran into the parameter -f issue.
-
John Pollard over 7 yearsI didn't read the comments before I ran the commands. How can you undo this? I dont see any issues, but im afraid I will months from now. Not sure how to test if this caused an issue for me.
-
Daniel Georgiev over 7 yearsTo remove it sudo rm /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun
-
Steve over 7 yearsI was getting this error when trying to install py35-PyQt5 from macports. The edit to default_pre.prf suggested in this answer fixed the error for me. Note that (as mentioned by yogodoshi above) for macports the file to edit is /opt/local/libexec/qt5/mkspecs/features/mac/default_pre.prf
-
Ben Hocking over 7 yearsWith homebrew, after installing [email protected] (which is required for the Ruby capybara gem), I found the relevant
default_pre.prf
file at:/usr/local/Cellar/[email protected]/5.5.1/mkspecs/features/mac/default_pre.prf
. I also tried Rudolf Ratusiński's approach, and while it got me over the first hump, it resulted in numerous spurious messages later that I did not get when I used this approach instead. -
ahay about 7 yearsThis worked great. There definitely is a missing parameter -f problem, but I couldn't get .prf changes to stick, so going to just deal with it for now.
-
Misha almost 7 yearsworks in Xcode8 and easier than the other steps. Thanks!
-
Dylan Pierce almost 7 yearsConfirmed it works on macOS Sierra 10.12.4 with Xcode 8 - Thank you!
-
moody over 6 yearsdont forget to add ': \' at the end
-
d1jhoni1b almost 6 yearsThis is still working on macOS High Sierra 10.13.5 with Xcode 9.4.1 - Thank you!
-
Dev M almost 6 years@Ricardo Stuven I Opened the file "default_pre.prf" but found that the line is already set correctly. then I tried the
xcode-select -switch
command but I got "invalid developer directory error". -
RNickMcCandless over 4 yearsConfirmed this works in macOS Catalina 10.15.2 with Xcode 11.3.
-
nerak99 about 3 yearsIf you are going to neg an answer, at least have the courtesy to give a clue as to why!