简体   繁体   中英

App Crashes at startup on Device but is fine on Simulator

My app works perfectly fine in the simulator but crashes on the Device. How do I figure out what makes it crash on the device?

Crash Log:

OS Version:      iPhone OS 5.1 (9B176)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x373a332c __pthread_kill + 8
1   libsystem_c.dylib               0x339b8208 pthread_kill + 48
2   libsystem_c.dylib               0x339b1298 abort + 88
3   GraphicsServices                0x30bfd87c GSRegisterPurpleNamedPort + 188
4   GraphicsServices                0x30bfe2bc GSEventInitialize + 64
5   UIKit                           0x36e6cc5a UIApplicationMain + 534
6   AppleIns HD                     0x00078bd6 0x77000 + 7126
7   AppleIns HD                     0x00078b80 0x77000 + 7040

This crash is occurring before your app has launched, ie. before your delegate's applicationDidFinishLaunchingWithOptions method is called.

Try:

  1. Rebooting your device.
  2. Disconnecting and reconnecting your device.
  3. Rebooting your computer.

Are you running on the same target in simulator and device? If so, just try the following to start debugging:

@try {
    retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([YOUR-AppDelegate-HERE class]));
}
@catch (NSException *exception) {
    NSLog(@"Exception - %@",[exception description]);
    exit(EXIT_FAILURE);
}

Place it on you main.m file, so whenever you don't catch an exception, and it bubbles up to the main, it won't make it crash without letting you know what happened.

Try deleting the application from your device. Also, what device are we talking about (iPhone 3GS, 4, 4s, iPad, iTouch (generation?) etc.

Here are the things I would check if deleting the app didn't solve anything (assuming you are running the app on the device via Xcode):

  1. Put an NSLog statement in the applicationDidFinishLaunchingWithOptions method in the AppDelegate. That will at least tell you whether springboard successfully launched the app.
  2. Make sure you haven't set any graphics files (the splash screen image, Storyboard,Nib file, UI element, etc) that are only designed for the retina display or not designed for the device you are running it on.
    1. If that NSLog statement executes, then start putting breakpoints in starting with anything you are doing in the applicationDidFinishLaunchingWithOptions and then step through the code until the app crashes. This should give you the place where you need to concentrate your troubleshooting. You can also use NSLog statements in place of breakpoints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM