Using Swift in a Legacy Objective C Project

I started learning Swift this week. I ran into my first time consuming problem when I tried to import my legacy Objective C classes into my Swift code. There are lots of good instructions on how to accomplish this task.

how-to-call-objective-c-code-from-swift

Unfortunately, I skipped over the one comment that said to include Foundation.h into my Objective C code:

Without it, you will see a lot of Unknown type error messages (e.g.
/Users/melling/Dropbox/dev/ios/Clock/Clock/Number.h:13:30: Unknown type name ‘NSInteger’)


#import <Foundation/Foundation.h>

@interface Numbers : NSObject

@property(assign, nonatomic) NSInteger numericalValue;
@property(assign, nonatomic) NSInteger dictId;

@property(strong, nonatomic) NSString *arabic;
@end

Advertisements