0

我正在尝试在我的 macOS 应用程序中创建 PDFKit 的 PDFView 的子类,该应用程序将遗留的 Objective-c 代码作为项目的一部分。

我的快速课程如下所示:

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.

任何帮助将不胜感激!

4

1 回答 1

0

我找到了答案,所以如果其他人偶然发现这个问题,我会发布。

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

于 2017-10-24T06:02:43.680 回答