我刚刚升级到 XCode 7.3,它似乎破坏了我的 PROJECT_NAME-Bridging-Header.h
BBCategoryType 是一个在名为 BBCategory.h 的文件中定义的枚举,该文件在我的 PROJECT_NAME-Bridging-Header.h 中导入:
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "BBCategory.h"
我还注意到,如果我删除 PROJECT_NAME-Bridging-Header.h,我会收到相同的错误 - 如果我将它添加回项目,我会收到相同的错误 - 就好像 XCode 7.3 甚至无法识别PROJECT_NAME-Bridging-Header.h 了。我已验证在我的build设置中也正确引用了桥接 header 。我已按照此处的所有说明进行操作以确保正确设置:
How to call Objective-C code from Swift
这是 BBCategory.h 的内容,它没有改变并且在升级到 XCode 7.3 之前完全正常工作,这肯定是问题开始的时候:
#import "PCFCategory.h"
/**
* Category class that is a subclass of PCFCategory.
*/
@interface BBCategory : PCFCategory
/**
* Enum that describes the type of Category, used in BBSubMenuViewController and PCFCategoryMap+BBAdditions.
*/
typedef NS_ENUM(NSUInteger, BBCategoryType) {
/// BBCategoryTypeFeatured for Featured Category.
BBCategoryTypeFeatured,
/// BBCategoryTypeNormal for Normal Category.
BBCategoryTypeNormal,
/// BBCategoryTypeHome for Home Category.
BBCategoryTypeHome,
/// BBCategoryTypeError if the category type is unknown
BBCategoryTypeError
};
这可能是 XCode 7.3 的一些错误,还是我需要进行一些更改才能使其正常工作?
这让我觉得 XCode 7.3 无法识别桥接 header 。一切都与 XCode 7.1、7.2 一起工作 - 7.3 就坏了
最佳答案
问题是你的枚举是在你的@interface内部定义的
虽然这在 Objective-C 中是有效的,但它似乎对 Swift 隐藏了它(我不确定这是否有意为之 - 绝对想知道是否还有其他人对此有更多了解)。
因此,您可以通过将枚举移到@interface 之外来修复它。
#import "PCFCategory.h"
/**
* Enum that describes the type of Category, used in BBSubMenuViewController and PCFCategoryMap+BBAdditions.
*/
typedef NS_ENUM(NSUInteger, BBCategoryType) {
/// BBCategoryTypeFeatured for Featured Category.
BBCategoryTypeFeatured,
/// BBCategoryTypeNormal for Normal Category.
BBCategoryTypeNormal,
/// BBCategoryTypeHome for Home Category.
BBCategoryTypeHome,
/// BBCategoryTypeError if the category type is unknown
BBCategoryTypeError
};
/**
* Category class that is a subclass of PCFCategory.
*/
@interface BBCategory : PCFCategory
...
关于objective-c - XCode 7.3 破坏了 Bridging-Header.h?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36461494/