Limit to how long Xcode will run an app on a device, before “Finishing”

applicationshigh sierraxcode

I'm trying to run an app on a device for a very long duration (in hours). I thought that Xcode would keep running the app, but it exited several times, saying "Finished running on my iPhone."

I'm using a MacBook Pro, so I thought the computer had just gone to sleep (which it had), but now that I'm on adapter power (plugged in, charged to 98%), it just did the same thing and stopped running the app with the same termination message. I need the app to keep running for hours to complete my test. The app will also not be in the foreground the entire time, other apps may be in the foreground as a critical component of these operations.

How can I make Xcode continue to run my app under test until I tell it to terminate?

Note: Xcode did not crash, and there was no indication the mac lost stability. I'm running the latest version as of this writing, Xcode 9.3, on macOS 10.13.4; this is a fresh install of the OS and Xcode (less than a week old), with all security updates applied, and only Xcode and Firefox installed. Xcode and Firefox are both running, with neither showing stability issues.

Best Answer

I would submit the app to TestFlight so you aren’t running in a constrained fashion. I know no way to circumvent this timeout but hopefully someone else will edit this post or answer if there is a better way (by hook or by crook if necessary).