ios - Objective C test class using Swift code -
i have swift protocol imodelidprovider in myprojectname folder. have created objective-c unit test class named remotemodelfactorytest in myprojectnametests folder. tests, remotemodelfactorytest must implement imodelidprovider protocol.
when #import "myprojectname-swift.h" utilize swift protocol in objective-c class, file not found.
if alter #import instruction #import "myprojectnametests-swift.h", header found not protocol (it's defined in myprojectname project, not in myprojectnametests project).
is there special in *tests projects utilize swift code ?
i know hacky , everything, did , worked copy public headers generated "project-swift.h" , paste whats needed .m file of test.
so copied this:
swift_class("_ttc10inventorum11imageentity") @interface imageentity : nsobject <ficentity> @property (nonatomic, copy) nsstring * imageid; @property (nonatomic) nsurl * retinaimageurl; @property (nonatomic) nsurl * nonretinaimageurl; @property (nonatomic, readonly) nsurl * imageurl; @property (nonatomic, readonly, copy) nsstring * uuid; @property (nonatomic, readonly, copy) nsstring * sourceimageuuid; @property (nonatomic) racsignal * rac_signalforimage; - (instancetype)init objc_designated_initializer; - (nsurl *)sourceimageurlwithformatname:(nsstring *)formatname; - (ficentityimagedrawingblock)drawingblockforimage:(uiimage *)image withformatname:(nsstring *)formatname; - (void)objc_settype:(nsstring *)type; @end and on top of have copied macros swift_class etc. tests building , passing testing swift code.
btw. dont forget set public on tested classes , methods in swift.
ios objective-c swift xcode6
No comments:
Post a Comment