在 swift 中子类化 'PDFView' - 找不到接口声明

Subclassing 'PDFView' in swift - cannot find interface declaration

我正在尝试在我的 macOS 应用程序中制作 PDFKit 的 PDFView 的子class,它有遗留 objective-c 代码作为项目的一部分。

我的 swift class 看起来像这样:

import Foundation
import Quartz

class customPDFView: PDFView
{
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
}

在构建过程中,我的 'projectName-Swift.h' 文件出现错误,它创建了这个:

SWIFT_CLASS("_TtC5NVivo13customPDFView")
@interface customPDFView : PDFView
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithFrame:(NSRect)frameRect SWIFT_UNAVAILABLE;
@end

上面代码的第二行产生错误: Cannot find interface declaration for 'PDFView', superclass of 'customPDFView'

注意:我的 'projectName.h' 文件包括 @import Foundation@import Quartz.

两行

如有任何帮助,我们将不胜感激!

我已经找到了答案 post 如果其他人偶然发现了这个问题,我也会找到答案。

在我的 <projectName>-Bridging-Header.h 文件中,我添加了 #import <Quartz/Quartz.h> 行,这解决了问题!