Search code examples
xcode8

Xcode 8 says "Do you want to add a stub?" How do I answer?


In Xcode 8, if you declare that a class (or struct) conforms to a protocol, but haven't implemented the required methods (functions?) Xcode will give this message "Type 'ClassName' does not conform to protocol 'ProtocolName'" which is true.

If you open the error by clicking the disclosure triangle, you will see a number of items with grey exclamation mark icons. Each item says "Protocol requires function ... do you want to add a stub?" I do want to add a stub! How do I tell it to add a stub for me?


Solution

  • The answer of raphh is right but xcode is still a little buggy here (at least for me),

    If you don't select the Fix-it right after compiling the dot mark transform to exclamation mark and you can't make it appear again unless you try to build one more time.

    Right after building : Dot error icon

    When you don't do the Fix-it right away : exclamation mark error icon

    You have to re-build to get the dot icon again when you have several methods to implement and you did do the Fix-it for the first one.