etayluz
etayluz

Reputation: 16416

XCode 7.3 broke Bridging-Header.h?

I just upgraded to XCode 7.3 and it seems to have broken my PROJECT_NAME-Bridging-Header.h

I am receiving this error: enter image description here

BBCategoryType is an enum defined inside a file called BBCategory.h, and that file is imported within my 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"

I also noticed that if I remove the PROJECT_NAME-Bridging-Header.h, I receive the same error - and if I add it back to the project I receive the same error - as if XCode 7.3 doesn't even recognize the PROJECT_NAME-Bridging-Header.h anymore. I have verified that the bridging header is correctly referenced in my build setting as well. I have followed all the instructions here to ensure that it is properly set up:

How to call Objective-C code from Swift

Here is content of BBCategory.h which has not changed and was completely working prior to upgrade to XCode 7.3 which is certainly when the problem started:

#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
};

Could this be some bug with XCode 7.3 or do I need to make some change for it to work?

I have also noticed that the bridging header is appearing in red below: enter image description here

which makes me think that XCode 7.3 cannot recognize the bridging header. Everything was working with XCode 7.1, 7.2 - with 7.3 this broke

Upvotes: 3

Views: 425

Answers (1)

Hamish
Hamish

Reputation: 80801

The problem is your enum is defined inside your @interface

Although this is valid in Objective-C, it appears to conceal it from Swift (I'm not sure if this is intended or not - would definitely like to know if anyone else knows more about this).

You can therefore fix it by moving the enum outside the @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

...

Upvotes: 4

Related Questions