英文:
Getting compilation errors when trying to add QR code scanner to a Qt project
问题
我正在尝试将QR码扫描器添加到我的iOS项目中,该项目使用Qt Quick编写。
我在这个示例中找到了如何使用本机API实现它的方法。
我已将QRCodeReaderViewController/*文件添加到我的项目并尝试构建它。出现了奇怪的编译错误。我怀疑需要启用一些Xcode构建设置,但我不知道如何使用qmake来做。
../ios/QRCodeReaderViewController/QRCodeReaderViewController.m:46:1: 错误: 无法在使用手动引用计数的文件中合成弱属性
@implementation QRCodeReaderViewController
../ios/QRCodeReaderViewController/QRCodeReaderViewController.m:107:5: 错误: 无法在使用手动引用计数的文件中创建__weak引用
__weak typeof(self) weakSelf = self;
英文:
I'm trying to add a QR code scanner to my iOS
project written using Qt Quick
.
I've found this example on how to achieve it using native APIs.
I've added QRCodeReaderViewController/* files to my project and trying to build it. Getting weird compilation errors. I suspect some Xcode build settings are required to be enabled, but I don't know how to do it using qmake
.
../ios/QRCodeReaderViewController/QRCodeReaderViewController.m:46:1: error: cannot synthesize weak property in file using manual reference counting
@implementation QRCodeReaderViewController
../ios/QRCodeReaderViewController/QRCodeReaderViewController.m:107:5: error: cannot create __weak reference in file using manual reference counting
__weak __typeof__(self) weakSelf = self;
答案1
得分: 1
如在文档中所述(不幸的是它在“文档存档”中,但我希望它仍然有效),您可以在您的**.pro**文件中尝试以下内容:
ios {
QMAKE_OBJECTIVE_CFLAGS += -fobjc-arc
}
如果这不起作用,您还可以尝试将QMAKE_IOS_DEPLOYMENT_TARGET
设置为类似于11.0
或更高的值,因为可能会出现与较新的编译器版本相关的问题。
英文:
As it's stated in the documentation (unfortunately it's in "Documentation Archive", but I hope it still works), you can try this in your .pro file:
ios {
QMAKE_OBJECTIVE_CFLAGS += -fobjc-arc
}
If this doesn't work, you may also try to set QMAKE_IOS_DEPLOYMENT_TARGET
to something like 11.0
or higher, because there might be issues with newer compiler versions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论