Question: How do I get Xcode to report the missing return?
Below is a new Xcode 11 test-app. I added the shouldReturnAnObject method with an empty @try/@catch block and no return value. This compiles and analyzes without warnings or errors.
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (nonnull id)shouldReturnAnObject {
@try {
} @catch (NSException *exception) {
} @finally {
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
id obj = [self shouldReturnAnObject];
NSLog(@"obj: %@", obj);
}
@end
If I remove the @try block from it fails to compile with the error: Control reaches end of non-void function. This is the behavior I expect for any method with no return return.
Versions:Xcode 11.5, macOS 10.15.5. No build settings changed.
Adding -Wall doesn't change the behavior.
I understand Cocoa best practice is to use exceptions only as exceptional. The real app uses exception rarely, and only to guard against truly exceptional behavior. I'm providing a simple test-app to focus on the issue.
I believe this behavior has existed in Xcode/Clang for a long time. If the behavior is intentional can someone explain why this behavior exists?whi
Related info: I have also built quick test apps in:
- C++ (Clang++) : compile fails with the error
-Wreturn-type - Java () : compile fails with
error: missing return statement - Objective-C++ (using a .mm file): no warnings, no errors, compile succeeds

