Reference class definition from prefix header in swift

Viewed 324

I'm adding swift code to an existing Objective-C project. I'm having problems referencing a definition from the existing prefix header.

I have a class called MyClass, defined in Objective-C with .h:

@interface MyClass
+(instancetype)myClass;
-(void)doStuff;
@end

And .m:

@implementation MyClass
+ (instancetype) myClass
{
    // More to it than this, but this illustrates the setup
    return [[MyClass alloc] init];
}

- (void)doStuff
{
    // Do something interesting
}
@end

The prefix header MyProj-Prefix.pch contains:

#define MYCLASS MyClass
#define SOMEVAR @"Hello"

I have created a bridging header which contains:

#import "MyProj-Prefix.pch"

The project contains Objective-C code that uses the class definition, e.g.

[[MYCLASS myClass] doStuff];

I would like to mirror this in my new swift code. I can see and reference the defined variable, but the defined class isn't visible. e.g.

let someStr = SOMEVAR // This compiles
MYCLASS.myClass.doStuff() // MYCLASS isn't visible

Any pointers on how to achieve this? I'm not even sure if this is possible in swift.

1 Answers
Related