When I declare a class that I want to conform to a protocol, Swift will show me a message saying that I don't conform to that protocol until all of the protocol's requirements have been met.
Is there a way to get the compiler to give me more specific details about which requirements I'm missing or why I'm not conforming to that protocol or do I always have to open the source code for that protocol with my class's source code side by side and do a manual eye-ball comparison?
To clarify, I'm not asking about any specific protocol in particular, in fact I'm really looking for better support in enforcing my own protocols.
The Issue Navigator
(exclamation icon on the left side panel, or CMD+4
) will reveal which protocols are not being conformed to and why:
Is there a way to get the compiler to give me more specific details about which requirements I'm missing?
Yes, the full compiler output tells you exactly which requirements are missing:
Simple example:
class A : Equatable {
}
Compiler output:
error: type 'A' does not conform to protocol 'Equatable' class A : Equatable { ^ Swift.Equatable:28:17: note: protocol requires function '==' with type '(A, A) -> Bool' public func ==(lhs: Self, rhs: Self) -> Bool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With