Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How debug after closing application

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.

like image 981
Szu Avatar asked Apr 01 '14 10:04

Szu


People also ask

Can you go back when debugging?

So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step.

How do you Debug applications?

Debugging an application involves building the application in debug mode (iOS or Android) and launching the application in an iOS or Android emulator or device. You can then use the Google Chrome debugger to debug the application.


2 Answers

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

like image 125
Asaf Manassen Avatar answered Oct 18 '22 07:10

Asaf Manassen


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.

like image 3
Nils Ziehn Avatar answered Oct 18 '22 09:10

Nils Ziehn