遇到在尝试将QR码扫描器添加到Qt项目时出现编译错误。

huangapple go评论73阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月4日 23:40:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401182.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定