How debug after closing application

3 Solutions Collect From Internet About “How debug after closing application”

Answering your (1) question:
Instead of using NSLog you can just print your logs to a file or use a remove loging framework like testflight. I am not really sure why you have to disconnect your app from xcode thought, or do you mean you have to terminate the debuging session by closing the app? If that is the case, if you just ‘run’ again, the starting point should be similar as if you just started the app. If you put the app to background, the debug session is not canceled.

Maybe even easier than storing them in a logfile you can just append your logs to an array that you store in the NSUserDefaults:

NSMutableArray* logs =
[[[NSUserDefaults standardUserDefaults] objectForKey:@"logs"] mutableCopy];
NSString* log = [NSString stringWithFormat:YOUR LOG HERE];
[logs addObject:log];
[[NSUserDefaults standardUserDefaults] setObject:logs forKey:@"logs"];

You can later read them if you use

NSMutableArray* logs =
[[[NSUserDefaults standardUserDefaults] objectForKey:@"logs"] mutableCopy];
NSLog(@"logs %@",logs);

Answering your (2) question:
I don’t know whether you are aware that you can make the iPhone Simulator simulate a location without xcode. When you are in the iPhone Simulator go to the Debug Menu (not in xcode, in the simulator) and go to the location. This location remains between closing the app and reopening it.

If you want to see the logs from your application
under XCode choose ‘Window’ sub menu and there ‘Devices’ sub menu (you can use shift+cmd+2)

Device sub menu

on the opened screen in the bottom of the screen you’ll see the log from the device even if it isn’t in debug state (if you don’t see it locate the little up arrow in the bottom left and click on it
log screen
).

if your device weren’t connected you can see crash reports there when you connect it

I use iConsole to view log just inside the app.

It is very helpful when I need to test a app with multiple devices together, in which case I could not connect them to Xcode at the same time.