"string.h"在构建适用于iOS的qt应用程序中找不到消息



我最近将Xcode更新到10.0版本,之后当我尝试为iOS构建版本时,我遇到了以下问题。

1:04:17:运行项目Diasteca的步骤... 11:04:17: 开始: "/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake"/Users/belladellifabio/Desktop/QtProjects/Diasteca/mqtt_test/mqtt_test.pro -spec macx-ios-clang CONFIG+=iphoneos CONFIG+=device CONFIG+=qml_debug 项目消息:该项目使用私有标头,因此将绑定到此特定的Qt模块构建版本。 项目消息:针对其他版本的Qt模块运行此项目可能会在任何时间点崩溃。 项目消息:这不是一个错误,而是使用Qt内部的结果。你已经被警告了! 11:04:18:进程"/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake"正常退出。 11:04:18:开始:"/usr/bin/make"qmake_all make:为"qmake_all"无所事事。 11:04:18:进程"/usr/bin/make"正常退出。 11:04:18:开始:"/usr/bin/make"/Applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -fPIC -std=gnu++11 -arch arm64 -arch x86_64 -Xarch_arm64 -miphoneos-version-min=12.0 -Xarch_arm64 -isysroot/Applications/Xcode.app/Content/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk -Xarch_x86_64 -mios-simulator-version-min=12.0 -Xarch_x86_64 -isysroot/Applications/Xcode.app/Content/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -fobjc-nonfragile-abi -fobjc-legacy-dispatch -fembed-bitcode-marker -wall -w -DQT_COMPILER_SUPPORTS_SSE2 -DMQTT_TEST_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../Diasteca/mqtt_test -I. -I../../../../Qt/5.11.1/ios/mkspecs/common/uikit -I../../../../Qt/5.11.1/ios/include -I../../../../Qt/5.11.1/ios/include/QtNetwork -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1 -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1/QtCore -I../../../../Qt/5.11.1/ios/include/QtCore -I. -I../../../../Qt/5.11.1/ios/mkspecs/macx-ios-clang -o qmqttclient.o ../../Diasteca/mqtt_test/qmqttclient.cpp clang: 警告: 没有这样的系统根目录: '/Applications/Xcode.app/Content/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk' [-Wmissing-sysroot] clang: 警告: 没有这样的 sysroot 目录: '/Applications/Xcode.app/Content/Developer/Platform/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk' [-Wmissing-sysroot] 在包含的文件中 ../../Diasteca/mqtt_test/qmqttclient.cpp:30: 在包含的文件中 ../../Diasteca/mqtt_test/qmqttclient.h:33: 在包含的文件中 ../../Diasteca/mqtt_test/qmqttglobal.h:33: 在包含的文件中 ../../../../Qt/5.11.1/ios/include/QtCore/qglobal.h:47: 在/Applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:202 中包含的文件中: 在/Applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61 中包含的文件中:/Applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15:致命错误:找不到"string.h"文件

可能真正的问题不是找不到文件错误,而是与 qty 尝试使用系统上不再安装的 SDK 构建应用程序的事实有关。这是一个qt问题吗?如何指定用于构建应用的 iOS SDK 版本?可能吗?

最后,我找到并删除了.qmake.cache和.qmake.stash文件。我已经重新启动了QtCreator,现在它似乎可以工作了。

Qt将SDK信息存储在构建输出和.pro.user文件的深处。 删除用户文件(如果您有自定义构建步骤,您可能需要备份用户文件(、完整(影子(构建树并修改您的 .pro 文件,以便没有QMAKE_MAC_SDK = macosx10.13这样的行。

然后调用 qmake 并再次构建您的项目,不一致应该消失了。

当Qt期望的iOS SDK与您安装的iOS SDK不同时,就会发生这种情况。例如,Qt 5.13.1 需要 iPhoneOS13.1.sdk,但我的 Xcode 目前有 iPhoneOS13.2.sdk:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  7 root  wheel  224 Nov  5  2019 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk

为了解决这个问题,我们可以让Qt使用iPhoneOS13.2.sdk:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  7 root  wheel  224 Nov  5  2019 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ sudo ln -s iPhoneOS.sdk iPhoneOS13.1.sdk
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:20 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jul 22 14:20 iPhoneOS13.1.sdk -> iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
$ sudo ln -s iPhoneSimulator.sdk iPhoneSimulator13.1.sdk
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jul 22 14:39 iPhoneSimulator13.1.sdk -> iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk

我遇到了类似的问题,因为我的 xcode 项目是由不同的 XCode SDK 创建的,并且是由 CMake 生成的,所以我删除了缓存并解决了问题。

最新更新