Swift protocol cannot use in .h file of objective-c

Hi all,
I have a swift protocol which need use in objective c code. The protocol is:

@objc public protocol MyProtocol {
    var Id: String {get}

And into the header file of objective-c, I have a method:

- (void)trackFlow:(MyProtocol *)flow //Error: Expected a type

What I am wrong here? or we cannot use Swift's protocol into the header file of objective c?

- (void)trackFlow:(id<MyProtocol>)flow;
Also you need to import targetName-Swift.h // replace with your target's name.

1 Like

import targetName-Swift.h just in .m file. But I need to use the protocol in .h file

@linqingmo you right.Thanks for your help.

Terms of Service

Privacy Policy

Cookie Policy