objective c - Type "SwiftClass" cannot conform to protocol "ObjcProtocol" because it has requirements that cannot be satisfied -


i have objective-c protocol i'm trying implement in swift class. example:

@class anobjcclass;  @protocol objcprotocol <nsobject>     - (void)somethingwithanargument:(anobjcclass *)arg; @end 

when try conform in swift class this:

@objc class swiftclass: nsobject, objcprotocol {     // ... } 

i following scary compiler error:

type "swiftclass" cannot conform protocol "objcprotocol" because has requirements cannot satisfied.

how resolve this?

ensure classes referenced protocol included in bridging header.

this error happens when 1 of types used in protocol (the protocol itself, return type, argument type) not included in swift bridging header.

objective-c classes can happily implement protocol because of @class anobjcclass forward declaration, appears swift classes can't implement protocols use classes forward-declared.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -