Xcode 8 Warning "Instance method nearly matches optional requirement"
One reason you might get this error has to do with method access modifiers. For example if you didn't define the function as public. So for methods on the CLLocationManagerDelegate case, changing:
func locationManager(_ manager: CLLocationManager,
didChangeAuthorization status: CLAuthorizationStatus)
to:
public func locationManager(_ manager: CLLocationManager,
didChangeAuthorization status: CLAuthorizationStatus)
(i.e. make the method public) gets rid of the warning and the method get called as expected. Note that autocomplete doesn't put the public access modifier on the method.
After hours of searching I found this - Swift 3 ObjC Optional Protocol Method Not Called in Subclass
You can workaround the bug by prefixing the objective-c declaration on the function
@objc(tableViewSettingsDidChange:notification:)
func tableViewSettingsDidChange(_ notification:Notification)
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.