Home > Mobile >  How to resolve colliding protocol names in Swift project
How to resolve colliding protocol names in Swift project

Time:09-22

I've got a Swift project that leverages multiple cocoapods / 3rd party libraries. For sake of simplicity, let's say that both library A and library B have a protocol called MyProtocol.

In my app, I'd like to conform to library A's MyProtocol, but Xcode keeps saying "MyProtocol is ambiguous for type lookup in this context." I assume that's because there are two flavors of MyProtocol, and it can't tell which one I'm referring to.

Is there a way around this error or a way to tell Xcode which version of the protocol I'm trying to implment? Thanks.

CodePudding user response:

Add the package name before the protocol: A.MyProtocol or B.MyProtocol.

  • Related