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

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

本文关键字:usr 运行 bin xcodebuild 协议 许可 确认 错误 项目 创建者 Xcode      更新时间:2023-10-16

我刚刚安装了Qt 5.5,这是第一次在OS X上使用Qt Creator。当我第一次安装Qt时,它给了我一条错误消息"Xcode 5未安装",我觉得这很奇怪(我有Xcode 7测试版),但安装无论如何都成功完成了。

现在,当我开始或打开一个项目时,我会收到错误:

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

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

xcode select:error:工具"xcodebuild"需要xcode,但活动的开发人员目录"/Library/developer/CommandLineTools"是命令行工具实例

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

>=Xcode 8

正如Bruce所说,在Xcode 8中,当Qt试图在应该查找xcodebuild的时候查找xcrun时,就会发生这种情况。

打开文件:

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

替换:

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

带有:

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

~>Xcode 8

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

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

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

使用以下命令确认许可协议:

sudo xcodebuild -license

这将提示您仔细阅读许可协议。

输入agree以接受条款。

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

更好的方法是创建符号链接:

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

因此,您不必为所有目标更改.prf文件。

这将完成任务:

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

在你的终端上运行这个。

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

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

总结:

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

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

这个:

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

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

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

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

基本上,问题是您指向/Library/Developer/CommandLineTools的xcode不允许您接受术语&条件所以在安装&重置位置,一切都应该正常

对我来说,正确工作的唯一方法是用'#'注释关于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.")

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

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

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

工作。也就是说,它在命令行中启动了一个同意程序,我在仔细阅读了所有14页的内容后同意了。

我不需要编辑任何内容。

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