0

When an app is attached to the Xcode debugger, none of the usual lifecycle methods (applicationWillResignActive:, applicationWillTerminate:, etc.) or notifications (UIApplicationWillTerminateNotification, etc) are triggered.

Is there any way for the app to know it's about to be stopped or re-deployed? Perhaps by trapping a signal?

rmaddy
  • 307,833
  • 40
  • 508
  • 550
sartak
  • 623
  • 4
  • 16
  • There is a way to determine [whether you're running in the debugger](https://stackoverflow.com/a/4746378/290913), which I use to autosave my current state much more frequently. However it'd be nice to get notified directly so I'm not wasting CPU and disk resources. – sartak Feb 24 '18 at 00:09
  • If you want a normal notification, you can press the home button to terminate the app/resign active... The intent of Xcode debugging is for developing an app, maybe if you explain your use case it will make more sense. – Cobra Feb 24 '18 at 01:17

2 Answers2

1

Nope. For all intents and purposes, the STOP button in Xcode immediately terminates the application. There isn't a way to catch this.

bbum
  • 161,681
  • 23
  • 270
  • 358
0

applicationWillResignActive and applicationDidEnterBackground and their counterparts do get triggered when you press the home button on the device or simulator (or when you come back). I don't think you can catch the ones related to termination.

kid_x
  • 1,245
  • 1
  • 10
  • 30