C++ Qt Creator - 项目错误:Xcode 设置不正确。您可能需要通过运行 /usr/bin/xcodebuild 来确认许可协议

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33728905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:18:44  来源:igfitidea点击:

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

提问by 123

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.

我刚刚安装了 Qt 5.5 并且第一次在 OS X 上使用 Qt Creator。当我第一次安装 Qt 时,它给了我一条错误消息“Xcode 5 not installed”,我认为这很奇怪,(我有 Xcode 7 beta) ,但无论如何安装成功完成。

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.

项目错误:Xcode 设置不正确。您可能需要通过运行 /usr/bin/xcodebuild 来确认许可协议。

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

当我/usr/bin/xcodebuild在终端中运行时,我得到以下信息:

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

xcode-select: 错误:工具“xcodebuild”需要 Xcode,但活动开发者目录“/Library/Developer/CommandLineTools”是命令行工具实例

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?

我不确定 Xcode 与 Qt Creator 有什么关系,除非它与访问库以实现跨平台兼容性有关,但是有没有办法解决这个问题?

回答by 123

>= Xcode 8

>= Xcode 8

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

在 Xcode 8 中,正如 Bruce 所说,当 Qt 试图寻找xcrun它应该寻找的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

~> Xcode 8

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

在 Xcode 8 之前,安装 Xcode 后安装命令行工具时会出现此问题。会发生什么是Xcode-select开发者目录被指向/Library/Developer/CommandLineTools

Point Xcode-selectto the correct Xcode Developer directory with the command:

Xcode-select使用以下命令指向正确的 Xcode Developer 目录:

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 agreeto accept the terms.

输入agree以接受条款。

回答by Rudolf Ratusiński

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

如果您更改内容,Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf则它仅适用于桌面套件,而不适用于 ex。模拟器。

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.

所以您不必为所有目标更改 .prf 文件。

回答by Shnd

This will do the trick:

这将解决问题:

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

Run this in your terminal.

在您的终端中运行它。

回答by Bruce

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

对于 Xcode 8 的用户,还有一个问题。在 Qt 5.7.1 发布之前,请参阅此处的临时解决方案:

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

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.prfin a text editor, and replace this:

Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf在文本编辑器中打开,并将其替换为:

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

with this:

有了这个:

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

回答by Remik Ziemlinski

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/configureon line 551 so that it looks like:

如果您使用 XCode 8.x 从源代码构建 Qt,则必须更改第qt-everywhere-enterprise-src-5.7.0/qtbase/configure551 行文件中的“-find”参数,使其看起来像:

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

回答by Ramses

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

设法解决它安装完整版的 Xcode,同意条款,然后使用xcode-select --reset.

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

基本上问题是您指向的 xcode/Library/Developer/CommandLineTools不允许您接受条款和条件。所以在安装和重置位置后,一切都应该没问题

回答by nerak99

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

只是为了本着“这对我有用”的精神为许多旧答案添加一点,我发现通过启动 Xcode,登录到我的开发人员帐户(只是一个免费帐户),然后在“位置”中设置命令工具. 我可以得到

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

'sudo /usr/bin/xcodebuild -license 同意'

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.

上班。即它在命令行中启动了一个同意过程,我在仔细阅读了所有 14 页的内容后同意了。

I did not have to edit anything.

我不必编辑任何东西。

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

我的系统是 Mojave 10.14.6 和 Xcode 10.3 (10G8)。

回答by Marcelo

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

对我来说,正确工作的唯一方法是用“#”注释有关 xcrun 的行:

# 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

在文件中:Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf