0

I have a model

@interface Section : NSObject
@property (nonatomic, strong) NSString *sectionId;
@property (nonatomic, strong) NSString *title;

+(instancetype)createObject:(NSDictionary *)sectionInfo;    
@end

My bridging header looks like this

// MyProj-Bridging-Header.h    

#ifndef MyProj_Bridging_Header_h
#define MyProj_Bridging_Header_h

#import "Section.h"

#endif /* MyProj_Bridging_Header_h */

My Swift controller looks like this

@objc class SampleSwiftVC : UIViewController {
    var supportedSectionInfo: Section?
}

I start getting compile time errors like

/*PathToProject*/Section.h:17:39: error: expected a type
+(instancetype)createObject:(NSDictionary *)sectionInfo;
                                  ^
<unknown>:0: error: failed to import bridging header '/*PathToProject*/MyProj-Bridging-Header.h'

I went over to the build settings and found that the header file reference is set for the Objective-C Bridging header key enter image description here

iosCurator
  • 4,356
  • 2
  • 21
  • 25

1 Answers1

0

I found the issue. The problem was that the ObjectiveC model was inherited from the NSObject.h. This was the actual problem because the Foundation class was not imported. Adding

#import <Foundation/Foundation.h>

before

@interface Section : NSObject

solved the issue

iosCurator
  • 4,356
  • 2
  • 21
  • 25