Question

I am trying to reproduce issue, which requires to close and reopen my application with a specific location. Here's my questions:

1) How can I view my logs (using NSLog command) when my iPhone is not connected to XCode?

2) Is it possible to set specific location (like center of the city) for iPhone simulator as default? I use GPX files but every time when I run project from scratch the location is set to unknown.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top