I have one enum which is in constant.h file ( Objective-C )
typedef NS_ENUM (NSInteger, EEFieldType) {
EEFieldTypeHighFields = 1,
EEFieldTypeMediumFields = 2,
EEFieldTypeLowFields = 3
};
I have one bridging file which is connect to swift code and importing one file which file name is profile.
(ModuleName-Bridging-Header.h)
#import "Profile.h"
profile file using below method which is not compiled in code.
- (EEFieldType)fieldTypeByPFType;
Error : Expected a type on EEFieldType.
[Answer moved and expanded from comments]
With the additional information on the use of a pre-compiled header file (
.pch) added in the comments, your problem comes down to Swift not using.pchfiles – they are an Objective-C compiler feature.In Objective.c
Profile.hcompiles as the header it depends on,constant.h, is imported by the.pch.In Swift
Profile.hproduces the missing type error as it does not importconstant.hwhich defines the type.Simply import
constant.hinProfile.h.Note: Doing this not only works for Swift it continues to work correctly for Objective-C – the
.pchfeature is a compiler option to speed up header processing and the Objective-C compiler will continue to use it, when it sees theconstant.himport inProfile.hit will simple skip it as already imported by the.pch.