objective c - Swift classes not found in iOS app when importing a mixed framework -
i have framework objective-c , swift mixed together. compiles alone when import in objective-c ios app, swift classes not found objective-c classes found. swift classes found inside framework when importing myframework-swift.h ios app , framework 2 different projects in same workspace.
defines module , embedded content contains swift code set yes targets , swift classes public @objc
i tried use @import myframework , #import <myframework/myframework-swift.h> no success.
i don't see myframework-swift.h header file in framework's headers directory projects. not sure if normal. generated in deriveddata
edit: managed reproduce problem simple workspace in xcode 8 (but same in 7.3):
- create new cocoa touch framework
testframeworkin objective-c create
a.hfile@class b; @interface : nsobject -(void)print:(b*)caller; @endcreate
a.mfile#import <foundation/foundation.h> #import "testframework-swift.h" #import "a.h" @implementation -(void)print:(b*)caller { [caller test]; }create
b.swiftfileimport foundation @objc public class b : nsobject { public func test() { print("test"); } }set
a.hpublic header- import
a.htestframework.h - try compile framework
here testframework-swift.h not found
- set
install objective-c compatibility headerno - try compile framework
now compiles !
- create new ios objective-c single view application app
update viewcontroller.m this
#import "viewcontroller.h" @import testframework; @interface viewcontroller () @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; b* b = [[b alloc] init]; a* = [[a alloc] init]; [a print: b]; } [...] @end
you should have error on b not a. set defines module yes in both project without success
ok found answer. install objective-c compatibility header must set yes , import must #import <testframework/testframework-swift.h>and not #import "testframework-swift.h" inside framework
Comments
Post a Comment