qt5 - QtCreator 在 MacOS SDK 11.1 上失败

标签 qt5 qt-creator xcode11 macos-big-sur

我有来自 brew 的 Qt5: /usr/local/Cellar/qt5/5.15.2/bin/

我使用 QtCreator 4.12.82。

我有 MacOS Big Sur 11.1 安装了 XCode ls/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk

当我在 QtCreator 中创建一个新的标准项目时,出现以下错误:

10:35:16: Running steps for project test2...
10:35:16: Starting: "/usr/local/Cellar/qt/5.15.2/bin/qmake" /Users/joefresna/VideoImageEdit/test2/test2.pro -spec macx-g++ CONFIG+=x86_64 CONFIG+=qtquickcompiler
Project WARNING: Qt has only been tested with version 10.15 of the platform SDK, you're using 11.0.
Project WARNING: This is an unsupported configuration. You may experience build issues, and by using
Project WARNING: the 11.0 SDK you are opting in to new features that Qt has not been prepared for.
Project WARNING: Please downgrade the SDK you use to build your app to version 10.15, or configure
Project WARNING: with CONFIG+=sdk_no_version_check when running qmake to silence this warning.
10:35:17: The process "/usr/local/Cellar/qt/5.15.2/bin/qmake" exited normally.
10:35:17: Starting: "/usr/bin/make" -f /Users/joefresna/VideoImageEdit/build-test2/Makefile qmake_all
/usr/local/Cellar/qt/5.15.2/mkspecs/features/mac/sdk.mk:22: *** ^.  Stop.
The platform SDK has been changed from version 11.0 to version 11.1.
This requires a fresh build. Please wipe the build directory completely,
including any .qmake.stash and .qmake.cache files generated by qmake.
10:35:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test2 (kit: Qt 5.15)
When executing step "qmake"
10:35:20: Elapsed time: 00:04.```

(请注意,即使我删除了构建目录,我仍然会收到有关删除该目录的警告)

QtCreator Kit 指向通过 brew 安装的 qt(如上所示)。 我试图在 QtCreator > Projects > Manage Kits > Kits > Compiler 中更改编译器 我从 /usr/bin 和 XCode 尝试了 GCC 和 Clang,但没有成功。

当我键入 xcodebuild -showsdks 时,我得到:

iOS SDKs:
    iOS 14.4                        -sdk iphoneos14.4

iOS Simulator SDKs:
    Simulator - iOS 14.4            -sdk iphonesimulator14.4

macOS SDKs:
    DriverKit 20.2                  -sdk driverkit.macosx20.2
    macOS 11.1                      -sdk macosx11.1

tvOS SDKs:
    tvOS 14.3                       -sdk appletvos14.3

tvOS Simulator SDKs:
    Simulator - tvOS 14.3           -sdk appletvsimulator14.3

watchOS SDKs:
    watchOS 7.2                     -sdk watchos7.2

watchOS Simulator SDKs:
    Simulator - watchOS 7.2         -sdk watchsimulator7.2

你知道如何解决这个问题吗?

最佳答案

在较新的 Xcode 中安装较旧的 Mac OS X SDK

已更新,使用 XCode 12.4 确认

https://github.com/phracker/MacOSX-SDKs托管已提取的直接 SDK 文件夹。

在此处查找包含所需 SDK 的 XCode 版本: https://developer.apple.com/support/xcode/

在此处下载包含所需 SDK 的 XCode 版本: https://developer.apple.com/download/more/ 或在这里: https://developer.apple.com/downloads/index.action

  1. 下载旧版 XCode。

  2. 下载后安装 DMG 文件(或解压 .xip 文件)并导航到 XCode.app

  3. 单击“显示包内容”打开应用程序

  4. 导航到/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

  5. 将 MacOSX.sdk 文件夹复制到一个临时位置。将 MacOSX.sdk 重命名为与步骤 4 中的链接相同的名称(例如 MacOSX10.15.sdk)

  6. 导航到/Applications/XCode.app 并单击 Show Package Content

  7. 导航到/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

  8. 粘贴复制并重命名的文件夹 (MacOSX10.15.sdk)。

  9. 重启 XCode

  10. 然后,新的 SDK 出现在 XCode 的组合框中:首选项、位置、命令行工具。选择您要使用的那个。

  11. 然后,对于所有项目,打开影子构建目录并删除名为“.qmake.stash”或通常为“.qmake.*”的文件。 (Command-Shift-Period 切换显示隐藏文件。) 此命令将删除所有实例,但会生成警告消息,因为许多目录不可访问:

    find/-name '.qmake.*' -delete

    如果要限制搜索,请使用起始路径:

    find/my/starting/path/-name '.qmake.*' -delete

  12. 在 QtCreator 中重建项目。

上述技术可能适用于其他平台的 SDK(例如/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs),但我还没有尝试过其他平台。

-- 感谢https://github.com/robvanoostenrijk ,谁为此提供了 key ,以及其他人。

关于qt5 - QtCreator 在 MacOS SDK 11.1 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65952224/

相关文章:

qt5 - raspberry2 上的eglfs -- * 未能添加服务 - 已在使用中?

linux - 在linux上部署一个Qt项目

c++ - 处理 Qt5 中 QRegularExpressions 中的重音字母

c++ - Qt 控制台应用程序 "WARNING: QApplication was not created in the main() thread"

ios - Xcode 11 调试变量 View 不显示类变量

ios - Settings.bundle 版本号正在更新为 $(MARKETING_VERSION)

c++ - QOpenGLFunctions 缺少重要的 OpenGL 函数

Linux 上的 QtCreator : 32-bits vs. 64 位

c++ - 没有警告输出时显示警告图标(Qt Creator IDE)

ios - 字体样式在 Xcode 11 Beta 中发生更改问题