applicationShouldTerminate not called in AppDelegate and NSApplicationWillTerminateNotification not being sent

Viewed 1087

I'm on XCode 11.1 on latest Catalina and none of my app's quit events are being called. applicationShouldTerminate in the AppDelegate nor do I get NSApplicationWillTerminateNotification if I observe it from anywhere. This is from the default quit behavior (Using the menu quit command, Command-Q, or closing the window with applicationShouldTerminateAfterLastWindowClosed returning YES) from the XCode app template using the default storyboard.

This happens with a brand new Xcode project template (If I start a new macOS "App" template, then add the applicationShouldTerminate method to the app delegate).

Other delegate methods like applicationShouldTerminateAfterLastWindowClosed are being called.

Am I doing something horribly wrong or is something messed up with Catalina?

3 Answers

Well, I figured it out and it's because it seems that NSSupportsSuddenTermination is on by default now.

To disable sudden termination, set this boolean property to NO in the app's information property list file Info.plist: enter image description here

NSSupportsSuddenTermination is also called 'Application can be killed immediately when user is shutting down or logging out' within Xcode, and seems enabled by default.

Go to Info.plist for your project and find "Application can be killed immediately when user is shutting down or logging out" key. Changes its value to "No"

Related