This function declaration is not a prototype

I'm getting this warning in the latest Xcode 9 editor when I load up an Objective-C project that did not give this warning in Xcode 8.3.3:


-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {

...

}


WARNING: This function declaration is not a prototype

There is a fix it to insert 'void' in the place of the () in the completion handler typedef, but when you do that you get another warning:

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {

...

}


WARNING: Conflicting parameter types in implementation of 'userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:': 'void (^ _Nonnull __strong)()' vs 'void (^__strong _Nonnull)(void)'


I tried commenting out this override method and let Xcode enter what it thinks is the correct entry via code completion. It gives me exactly what I had to begin with:


-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {

...

}


Which of course gives me the original warning. Is this just a bug or am I missing something here? Thanks!

Replies

I got exactly the same problem. I think it's a bug.

Looks like Xcode 9 Beta 2 has fixed this warning issue.

I'm implementing a bunch of the app delegate methods and see that it's fixed for userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:, but not for a few others. Going to file a bug since it appears that this is not the intent if it changed from beta 1 -> 2.

Happening to me with GM. Not tried the betas.

Yep

same. But following the spec at this link, I added "void" in the empty parentheses and it was happy https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SchedulingandHandlingLocalNotifications.html


(void (^)(void))completionHandler...

It is also happening in the released version (AppStore).


I have some C functions definitions like:


// *.h file
NSString *Strings_getSomeString();


and it is generating the warning: This function declaration is not a prototype. Insert 'void'