Debugging killed app in xcode debugger(Notification Debugging) - ios

My notifications is crashing the IOS App when the user clicks the notification after the app was killed and removed from the background/foreground. I don't know how to get debugging information if the app isnt being ran.

You need to edit your scheme, choose Run on the left bar. and Info on the top tab bar.
Change Launch to wait for executable to be launched.
Now, you can run the app. the app will not launch and therefore, will not crash.
get the notification, open it, and debug the crash.

Related

Debug app after device restart

I have an issue on my iOS app that occurs every time I restart my iOS device (i.e. after turning it off and on again). I turn off the device with the app in foreground, restart it and then relaunch the app from the background.
Obviously, the Xcode console doesn't show debug message when the device is turned off and I don't manage to know what happens to the app when the device is restarted. If I restart the app from Xcode, the issue disappears and everything works flawlessly again.
Also, it seems that the app is relaunching itself from the background when the device restarts. Is it possible to prevent this behaviour and force the app to restart from scratch when I tap on the app icon or on its screen from the multitasking?
Thanks.
If you want to force close apps, double tap the home button and then you can swipe away the background process.
To debug the process after restarting the device and opening the app again, you should be able to attach the Xcode debug console to the running process. In Xcode do:
Debug > Attach to process > [select your process]

App crash when relaunching from background

My app sometimes crash if it has been in the background for a while and I bring it back into the foreground. How can I debug this? Can I pull out the "console log" from the app even though it is not connected and running via Xcode?

iOS App shuts down when notification center and recently used app list are opened

My iOS app simply shuts down when I open notification center while the app is visible and in focus. Same thing happens if I double click the home button to show the recently used apps list.
This would seem to be an application lifecycle issue, but no errors are reported in Xcode.
How should I go about debugging this problem?

Can i display error occurred within an app if i'm not launching it with Xcode?

I have a problem with my app: if i launch it with Xcode all goes well. If i manually terminate The app and then i try to open it again(not running it with Xcode, but simply tapping the icon button) instead of reopening from the start, The app shows me the last screen i opened before terminating it and remain stuck, totally blocked. In that moment, i'm not under control of Xcode console: how can i visualize an error eventually occurred?
When you run your app from Xcode, it attaches a debugger to your app. This prevents the app from closing normally. You'll need to press the stop button in Xcode to detach the debugger and let the app quit so you can launch it from the iPad normally.

UIApplicationExitsOnSuspend and screen refresh

I have an app that has the UIApplicationExitsOnSuspend info list property set to TRUE.
And now I am noticing a curious issue.
I start up the app and let it run on my phone and do not touch my phone. Eventually the phone screen goes dark and the phone goes into standby mode. When I wake the phone up, what I see is a screenshot of the last screen displayed on the app. (This seems according to spec, since the Apple documentation says that in the process of moving an app to the background, ios takes a picture of the app and uses that for transitions when the app comes back to life). If I double click on the home button to see running apps, I do not see an instance of the app running. (again, working as intended since UIApplicationExitsOnSuspend is set to true).
My question is, how do I make sure that when the phone wakes up, it comes back to the default home screen and not the picture of the app ? Clearly the app is not running on waking up, so there is nothing I can do from within the app that will refresh the screen. I could try to exit when the app is going to background, but then apple guidelines say, never exit programatically!!.
Any ideas ?
You misunderstand what is happening. If you enable UIApplicationExitsOnSuspend, this means your app will terminate when normally the app would go to the background. If you run your app then let the phone sit idle until the screen goes dark, your app is still in the foreground so it is not terminated. When a device goes into standby mode, the current app is still the current app. When you wake the device, you are not looking at snapshot of your app, you are looking at your running app. Double-tapping the Home button at this point doesn't show your app because your app is the currently running app.
Your app will be terminated if you return to the home screen or switch to another app. But it will not terminate just because the device went into standby mode.
If you want your app to return to its main screen when the device is woken up, then you need to put code in the UIApplicationDelegate applicationDidBecomeActive: method to reset your user interface.

Resources