Search code examples
iphoneobjective-cxcodedebuggingios4

Application Failed to Launch in Time


How can I diagnose this error?

Application Specific Information:
    MyApp failed to launch in time

    Elapsed total CPU time (seconds): 4913.443 (user 3868.270, system 1045.173), 56% CPU 
    Elapsed application CPU time (seconds): 0.010, 0% CPU

    Backtrace not available

    Unknown thread crashed with unknown flavor: 5, state_count: 1

    Binary Images:
    0x2fe00000 - 0x2fe26fff  dyld armv7  <a11905c8ef7906bf4b8910fc551f9dbb> /usr/lib/dyld

Here is my didFinishLaunching method:

#pragma mark -
#pragma mark Application lifecycle

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

        if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")) 
        {
            NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
        }

        // Override point for customization after application launch.
        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];

        //Check for connectivity
        internetReach = [[Reachability reachabilityForInternetConnection] retain];
        [internetReach startNotifer];
        [self updateInterfaceWithReachability: internetReach];

        [window addSubview:navigationController.view];
        [window makeKeyAndVisible];

        return YES;
    }

Solution

  • You're probably doing a lot of setup work in your AppDelegate's application:didFinishLaunching method.

    You should make sure this function exits as soon as possible. Any setup-work that takes time (network access for example) should be done asynchronously in your application. While this is going on, you can show a spinner to indicate to the user that the application is loading.