XCode 7.3打破了Bridging-Header.h?

时间:2016-04-06 20:17:55

标签: objective-c xcode swift bridging-header

我刚刚升级到XCode 7.3,它似乎打破了我的PROJECT_NAME-Bridging-Header.h

我收到此错误: enter image description here

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。我已经验证在我的构建设置中也正确引用了桥接头。我已遵循此处的所有说明以确保正确设置:

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的一些错误,还是我需要做一些改变才能使用?

我也注意到桥接标题出现在下面的红色: enter image description here

这让我觉得XCode 7.3无法识别桥接头。一切都在与XCode 7.1,7.2一起使用 - 7.3这打破了

1 个答案:

答案 0 :(得分:4)

问题是你的枚举是在里面定义的你的@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

...
相关问题