I am making a Mac app, entirely in Swift. Now, I need to add an Objective-C function to the app, but I can\'t figure out how. I have very little knowledge about Objective-C, but
Here's the solution for an iOS app:
File Thing.h:
#import
@interface Thing : NSObject
void MyCreatePDFFile (CGRect pageRect, const char *filename);
@end
File Thing.m:
#import "Thing.h"
@implementation Thing
void MyCreatePDFFile (CGRect pageRect, const char *filename) {
// ... your code here ...
}
@end
In the bridging header:
#import "Thing.h"
Now your Swift code can see and call this function.