Preventing protocol methods from showing up twice in autocomplete

This is more of an annoyance and cosmetic issue than anything else, but there are some consistency issues with autocomplete in Xcode, and I’d very much appreciate if somebody has a solution for it.


Consider a protocol MyProtocol, which has a property and a method:

  • CommonHMAC in Swift
  • Select() from LINQ in swift 3.0?
  • In Swift, how would you write the scrollViewWillEndDragging withVelocity targetContentOffset method?
  • Convert Unicode (e.g. 1f564) to Emoji in Swift
  • How can I find the UIView for a specific UITabBarItem?
  • What does “% is unavailable: Use truncatingRemainder instead” mean?
  • public protocol MyProtocol {
        var variable: String { get }
        func method()
    }
    

    And a class A which adopts MyProtocol and implements the requirements in order to conform to the protocol:

    public class A { ... }
    
    extension A: MyProtocol {
        public var variable: String { get { return "String from A." } }
    
        public func method() {
            print("Method called.")
        }
    }
    

    The problem:

    When accessing the members of an instance of A, protocol methods show up twice, whereas properties only show up once:

    If everything is documented in code, it becomes clear that the protocol properties become hidden, while protocol methods remain visible in autocomplete. The same applies for default implementations of protocol methods – still visible.

    Another thing that makes this issue even more peculiar is that if an instance of e.g. A is created in the same file where the class is declared, and that instance’s members are accessed within the same file as well, then the protocol method disappears from autocomplete:

    But, if the same instance (which is now on the global scope) is called from another file, the protocol method reappears in autocomplete.

    So, my question is: does anybody know how to hide the duplicate protocol methods from autocomplete?


    Versions:

    Xcode: 7.3 (7D175)

    Swift: 2.2

    Solutions Collect From Internet About “Preventing protocol methods from showing up twice in autocomplete”

    This seems to be a bug. rdar://21701167 was filed last year.

    It could be caused by:

    • duplicates originating from Xcode document updates

    • duplicates from 3rd party Xcode document plugins

    • installing two versions of Xcode side-by-side

    It’s anyone’s guess really. It is sort of annoying. Sometimes I get 3 or 4 duplicates. I am using two versions of Xcode and I was using a 3rd party document plugin.