2

applicationDidFinishLaunching is never called in the running of my app(tested on real device and simulator) despite the fact that applicationDidBecomeActive is called. I can only find macOS solutions to this problem(here, here, and here)

In my info.plist file, I have Main storyboard file base name set correctly. I have a Storyboard entry point hooked up to my initial view controller. The app launches and I see everything I should, but applicationDidFinishLaunching is never called and I use that method to handle on-startup configuration and construction.

Based on the macOS posts, I tried dragging an object(yellow cube) into the IB hierarchy of the initial view controller, set its class as my app delegate class, and set it as the initial view controller's delegate. But applicationDidFinishLaunching is still never called.

The method signature is correct (I know this is a common issue for Swift projects)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    return YES;
}


- (void)applicationDidFinishLaunching:(UIApplication *)application{
   //code
}
maddie
  • 1,854
  • 4
  • 30
  • 66
  • using objective c, but yes I saw in other SO posts that was a common issue! – maddie Nov 15 '17 at 20:40
  • is it on iOS simulator or a device ? Did you tried uninstalling and running – ahmed Nov 15 '17 at 20:50
  • it doesn't work on either - so I should try uninstalling the app on the real device and simulator, and then try running again? – maddie Nov 15 '17 at 21:22
  • Please add your code for the relevant portion of your app delegate class. It could be as simple as an error in your method signature. – Paulw11 Nov 15 '17 at 21:24
  • Your method signature is incorrect. It should be `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` – Paulw11 Nov 15 '17 at 21:29
  • I also have that method (same signature as yours above), but I was under the impression it was a different method from `applicationDidFinishLaunching` ? – maddie Nov 15 '17 at 21:31
  • 4
    The [documentation](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623053-applicationdidfinishlaunching) for that method states "Tells the delegate when the app has finished launching. Don’t use. Instead, use `didFinishLaunchingWithOptions`". Since you have `didFinishLaunchingWithOptions` implemented, `didFinishLaunching` will not be called. – Paulw11 Nov 15 '17 at 21:32

1 Answers1

4

In the documentation for applicationDidFinishLaunching: it says:

Although not formally deprecated, do not use this method in your apps. Use the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods instead.

If you use application:didFinishLaunchingWithOptions: then applicationDidFinishLaunching: will not be called.

Guy Kogus
  • 7,251
  • 1
  • 27
  • 32