"No method with selector '%s' is implemented in this translation unit" warning is too aggressive

Originator:brent
Number:rdar://17806477 Date Originated:24-Jul-2014 11:11 PM
Status:Duplicate/16600230 Resolved:
Product:Developer Tools Product Version:Xcode6-Beta4 (6A267n)
Classification:Other Bug Reproducible:Always
 
Summary:
Xcode 6’s clang with “-Wselector” enabled now emits a warning when you reference an @selector() that is not implemented—not just not defined, but not implemented—in the same file. This is a very noisy error that doesn’t ever seem to indicate a bug in my code.

Steps to Reproduce:

1. Create an Objective-C project.

2. Enable a reasonable amount of warnings to ensure safety, including -Wselector.

3. Create an NSArray of NSStrings.

4. Set out to sort the array like so:

    array = [array sortedArrayUsingSelector:@selector(localizedStandardCompare:)];

5. Build.

Expected Results:
This perfectly sensible sort does not cause any warnings or errors.

Actual Results:
clang emits a warning on that line:

    No method with selector ‘localizedStandardCompare:’ is implemented in this translation unit

Regression:
Previous versions of Xcode warned for selectors that were not declared, but that encompassed selectors used in the frameworks or in other imported headers. The new behavior is much more aggressive.

Notes:
I assume that the warning was introduced with the idea that @selector() was mainly used to register actions and the like. While this is one common use, the frameworks, and especially the Foundation collections, are also full of methods that take a selector and perform it on objects under their control. NSObject and the Objective-C runtime also include a suite of methods and functions that are often used with selectors you don’t implement yourself.

Without excluding cases like these, this warning is uselessly noisy—it appears eight times in my code, never flagging an actual error—and turning it off will disable related warnings I really *do* want, leaving my code *less* safe than in Xcode 5. This warning should be reined in, removed, or given a separate flag from other -Wselector warnings.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!