tags:

views:

28

answers:

3

Hi Guys

I tried to deploy my application in real device.

But when it running , my application is crashed (be aborted).

How can i catch message error to display the error what make application be crashed?

Thank you.

A: 

Hello,

Mmm I don't know.

But you could try using the debugger or Instruments which allows a lot of debugging methods :-)

What is saying the console logs ?

Good luck !

Vinzius
A: 

When you connect your device to your computer, the organizer window in Xcode will allow you to view crash logs from the device. These can be helpful in locating the source of the problem.

If you run your app on the device by debugging from Xcode, you should be able to use bt in gdb when the debugger breaks at the point of the error. This will print a backtrace that shows where the error happened. You can move up the back trace to the point in your code that had the error by typing up in gdb.

GregInYEG
I deployed my app on some iPhone devices using Ad Hoc Distribution. Some devices run well but some devices was aborted. Some testing devices (what was aborted) are not connect Xcode so i can not debug by Xcode. I tried to using @try...@catch(NSException *e)... but i still can not catch the error.
haicnpmk44
A: 

First of all you can redirect Your logging to a file with this method:

+ (void)redirectNSLogToDocumentFolder {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);    
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];    
    NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];   
    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
}

just call it at the beginning of your app. After, all your NSLog() calls will be written to a file (with the date as name).

Then you can just connect your device to XCode and retrieve the file with the Organizer

dkk