简体   繁体   English

在 Swift 中访问 Objective-c 枚举,在单元测试目标中显示“在范围内找不到类型”

[英]Accessing Objective-c Enum in Swift showing "Cannot find type in scope" in Unit Test Target

I am developing an framework project which is initailly developed in objective-c and for new changes we are started making in swift.我正在开发一个框架项目,该项目最初是在 Objective-c 中开发的,并且我们开始迅速进行新的更改。

I have just created an header which have only enum declaration in objective-c.我刚刚创建了一个标题,它在objective-c 中只有枚举声明。 I am able to access it in swift file from framework target.我可以从框架目标在 swift 文件中访问它。

But when I try to compile the unit test target, I am getting a wired error saying但是当我尝试编译单元测试目标时,我收到一个有线错误说

"Cannot find type 'CertificateType' in scope" “在范围内找不到类型‘CertificateType’”

. .

Any Suggestion on this to fix the issue?有什么建议可以解决这个问题吗?

#ifndef CertificateType_h
#define CertificateType_h

typedef NS_ENUM(NSInteger, CertificateType) {
    
    CertificatePaid = 0,
    CertificateFree = 1,
    CertificateTrial = 2,
    
    CertificateUnknown = 15

};

#endif /* CertificateType_h */

Since it is already available SDK, I am unable to convert this into swift.由于它已经是可用的 SDK,我无法将其转换为 swift。

Have you made a bridging header and included that header file in it?您是否制作了桥接头并将该头文件包含在其中?

How do I call Objective-C code from Swift? 如何从 Swift 调用 Objective-C 代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM