I'm trying to debug an iOS app that sometimes exits "mysteriously". It dosn't happen while connected to Xcode, only when running alone on an iPhone device. I'm writing lots of debug information to files in the tmp directory but after the mysterious exits nothing helpful is contained there. It's as if it's terminated by iOS with no involvement of the app code itself. I would expect the iOS console might give a clue about what's going on but so far it's always been cleared and restarted sometime after the exit happened. IOW the earliest date/time in the iOS console is a little after the app exited, so nothing from the time of the exit is there.
The app uses very little memory and (according to the memory instrument) the memory doesn't grow with time. Of course that's measured only while the device is connected to Xcode and it never crashes then. It's cpu use is typically in the 10-20% range.
Q1. In OSX and Unix when the syslog file is cleared and restarted the old file is archived somewhere so it's available for a long time. Does that happen in iOS? How can I find and read the previous console file?
Q2. What causes the iOS console file to be cleared? It usually contains many hours of output but the last 4 times my app crashed it had only about 45 - 60 minutes of output and the crash was always just before the earliest console output. I'm wondering if whatever is crashing the app is also clearing the console output, although that seems unlikely.
Q3. Two of the last four exits happened when a phone call came in, but at other times incoming calls didn't crash the app. Does that give any hint about what's going on?
Q4. Is there a way to somehow persist the iOS console (i.e., take a snapshot) so I could look at a copy later?
To give some context: this is an app that records heart rate vs. time, both on a graph on the screen and also in a file for later use. The heart rate data comes from a bluetooth chest strap. For testing and debugging I'm using it myself in the gym. 9 times out of 10 it works fine for the hour or so while I'm exercising but 4 times lately it crashed. When it crashes I look at the iOS console as soon as I get home using the console view in Xcode but that's typically at least 45 minutes later and by then the output from the time of the crash has been cleared away. I wish I could look at it right away on the phone but I don't think that's possible. This is iOS 9.1 and Xcode 7.1.1. The app is a mix of Objective-C and Swift.