我正在使用 libzBar 在 swift 中扫描二维码,但我收到了这些错误。
.
第一个错误是关于弱引用,第二个是未声明的类型。 起初我以为我没有包含 ZBarReaderView.h 但在检查文件检查器后我发现文件正确添加为
我已经在 Objective-C 中添加了一个 ZBarReaderView
,它工作正常。我还查看了添加 EmbeddedReader
(ObjectiveC) 的示例项目。
所以我想知道为什么会出现此错误以及如何消除此错误?
解决方案:
To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.
最佳答案
看起来您没有创建桥接头。关注Apple Docs创建一个,然后在桥接 header 中导入 ZBarReaderView.h。
关于ios - swift:弱不能应用于导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30188413/