I’m writing a dynamic Framework (Proto.framework
) for OS X in Swift. I want to include code from a static library (libstat.a
) which is written in Objective C. Here’s what I’ve got:
// Dynamic.swift in Proto.framework
class Dynamic {
func doSomethingWithStat() {
Stat().statThing()
}
}
// Stat.h in libstat.a static library
@interface Stat : NSObject
- (void)statThing;
@end
// Stat.m
@implementation Stat
- (void)statThing {
NSLog(@"OK");
}
@end
In my target for Proto.framework, I have linked it to libstat.a. When I try to build Proto, naturally it doesn’t compile because it can’t find the definition for Stat().statThing()
. It doesn’t know the symbols for my static library. How do I tell it about that?
For applications, I’d use a bridging header and do #import <Stat/Stat.h>
. But the compiler errors out and tells me Bridging headers aren’t allowed in frameworks
. OK.
So I include it in my “umbrella header” (Proto.h
) but that tells me error: include of non-modular header inside framework module
. OK.
Making my Stat
library target Defines module: YES
doesn’t seem to change the error even after a clean build. So I’m not sure how to do this.
Can someone point me in the right direction?