ios - Cannot find protocol declaration for 'WCSessionDelegate' -
i new ios development. created swift class follows:
import watchconnectivity; import healthkit; @objc class blah : nsobject, wcsessiondelegate { ... }
i need @objc use class objective-c (that exists). problem when compiler creates bridge [productname]-swift.h, complains cannot find wcsessiondelegate. exact error:
cannot find protocol declaration 'wcsessiondelegate'; did mean 'nsurlsessiondelegate'?
swift_class("_ttc8test8blah") @interface blah: nsobject <wcsessiondelegate>
instead of implementing delegate, if change following, works.
@objc class blah : nsobject { ... func setsessiondelegate(delegate:wcsessiondelegate) -> blah { self.mdelegate = delegate; return(self) } }
i prefer former way. how resolve compilation error? thanks
it looks [productname]-swift.h
file adds include if mosules supported:
#if defined(__has_feature) && __has_feature(modules) @import objectivec; @import watchconnectivity; @import foundation; #endif
in case, , in yours too, disabled. if can't or won't enable them, can make sure include connectivity header each time, e.g.
#import <watchconnectivity/watchconnectivity.h> #import "myapp-swift.h"
Comments
Post a Comment