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" 

see https://stackoverflow.com/a/24064015/67824


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -