Debug app after device restart - ios

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]

Related

Debugging killed app in xcode debugger(Notification Debugging)

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.

Xcode does not deploy or launch Apple Watch simulator

I change the scheme to Apple Watch and hit run, the watch simulator shows up but my app icon is not even seen on the home screen of watch.
I have been trying for days now. I tried cleaning project, cleaning build folder, removing derived data, removing files in the watchOS DeviceSupport, restarting Xcode(9.2), restarting Apple Watch Simulator
(External Displays option does not shows Apple Watch Alternatives by the way)
Can you help with the possibilities that might cause this issue?
What else should I try?
Xcode does not launch my app on the watch simulator :/ this is the summary of the issue.
On the iOS(iPhone) simulator launch the Apple "Apple Watch" app (not your app) scroll all the way down to the buttom, down there your app should have a loading icon next to it, wait 20 minutes if the icon haven't shown up on the watch, restart your computer, with the option to relaunch all apps ticked to off, launch xcode, then try the above mentioned.
When trying out my first watchOS app, I was seeing the same behaviour. I could not find the app's icon in the simulator. The following is what I did.
I stopped the app in Xcode.
Launched it again.
This time I opened the main app in the iPhone simulator also.
The icon for the app appeared in the watch simulator among other apps and the app launched.
For ~10 seconds a loading indicator was shown.
I was able to continue debugging normally from then on.

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?

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.

Can't stop Xcode app execution in simulator?

Has anyone seen this before? Ever since I upgraded to Xcode 4.5.2, sometimes when I press Command-R to run an app in the simulator, the status in Xcode says "Running", but the app never starts in the simulator. When I press Command-., it says it is trying to stop, but never stops. Xcode basically is hung, I have to force quit. Hopefully there is a simple solution?
Try opening the simulator and deleting the application. Also try closing and re opening xcode. If this does not try restarting your computer. If you are still having the problem then you will have to uninstall xcode and reinstall it. (I have had that problem multiple times)
Strange, but works. Click on the 'iOS Simulator' icon in the Dock (https://stackoverflow.com/a/10277189/1514970).
This tends to work. I use Serge's find to click the icon in the dock - this then "wakes up" XCode to the fact that it needs to attach to the app in the simulator. Even though the attach never happens, a Command-Period at this point stops XCode without hanging it and having to do a Force Quit. Then, I can close down the Simulator, and do Command-R to run from XCode. This relaunches the simulator and attaches to the app process.

Resources