Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 Warning "Instance method nearly matches optional requirement"

I converted my (macOS) project to Swift 3 in Xcode 8 and I get the following warnings with several delegate methods I implement in swift classes:

Instance method 'someMethod' nearly matches optional requirement of protocol 'protocolName' 

I get this for several NSApplicationDelegate methods like applicationDidFinishLaunching and applicationDidBecomeActive:

enter image description here

But also for implementations of tableViewSelectionDidChange: enter image description here

enter image description here

I used code completion to insert the method signatures and also tried copying them from the SDK-headers to rule out typos. The warnings just don't disappear and the methods are never called.

What am I missing here?

like image 612
codingFriend1 Avatar asked Sep 14 '16 16:09

codingFriend1


1 Answers

We contacted Apple Developer Technical Support (DTS) with this issue. They replied that this is a bug in Xcode 8.

We submitted a bug report and hope for a quick update. (Apple Bug Report ID: 28315920).

If you experience a similar issue, please also file a bug report (referring to ours) so the Apple engineers see its not a single case.


Update for Xcode ≥ 8.1

The problem seems fixed now, at least for the delegate methods we are using in our project.

like image 127
codingFriend1 Avatar answered Nov 06 '22 20:11

codingFriend1