Methods required by UIApplicationDelegate do not conform to -Wstrict-prototypes

Originator:ravron
Number:rdar://32951376 Date Originated:2017-06-23
Status:Open Resolved:
Product:UIKit Product Version:
Classification:Other Bug Reproducible:Always
 
UIApplication.h defines the UIApplicationDelegate protocol. Some of the protocol's methods accept block parameters declared as:

void (^)()

However, one of the new warnings Xcode 9 suggests that I apply to my project is Clang's -Wstrict-prototypes. That warning complains about void(^)(), correctly saying it should be void(^)(void) instead. This means that in a class implementing the UIApplicationDelegate protocol, the following method implementation will have a compiler warning:


- (void)application:(UIApplication *)application
    handleActionWithIdentifier:(NSString *)identifier
          forLocalNotification:(UILocalNotification *)notification
             completionHandler:(void (^)())completionHandler  // warning: this function declaration is not a prototype
{}

But if I try to fix this, by changing the declaration to include the extra void, I get a different warning:

- (void)application:(UIApplication *)application
    handleActionWithIdentifier:(NSString *)identifier
          forLocalNotification:(UILocalNotification *)notification
             completionHandler:(void (^)(void))completionHandler
{}
// Conflicting parameter types in implementation of 'application:handleActionWithIdentifier:forLocalNotification:completionHandler:': 'void (^ _Nonnull __strong)()' vs 'void (^__strong _Nonnull)(void)'

So the only thing I can do is:

- (void)application:(UIApplication *)application
    handleActionWithIdentifier:(NSString *)identifier
          forLocalNotification:(UILocalNotification *)notification
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
             completionHandler:(void (^)())completionHandler
#pragma clang diagnostic pop
{}

This should be easy to fix. Just apply -Wstrict-prototypes to UIApplication.h and fix the resulting warnings. For completeness, here is the full list of broken method declarations in that file:

- application:handleActionWithIdentifier:forLocalNotification:completionHandler:
- application:handleActionWithIdentifier:forRemoteNotification:withResponseInfo:completionHandler:
- application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
- application:handleActionWithIdentifier:forLocalNotification:withResponseInfo:completionHandler:
- application:handleEventsForBackgroundURLSession:completionHandler:

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!