iOS 15 prewarming and didFinishLaunchingWithOptions

Hi,

Just want to understand what is the current state of iOS 15 prewarming app delegate behaviour.

There is a lot of confusion (and a lack of documentation) about which app delegate methods are called during prewarming. It's not clear if didFinishLaunchingWithOptions will be called or not during prewarming.

A lot of applications are counting on UserDefaults and Keychain access in didFinishLaunchingWithOptions, but sadly these two features seems to be unavailable during prewarming causing issues.

Some users say that this was the case before 15.4 and that from 15.4 the didFinishLaunchingWithOptions app delegate method is no more called during prewarming.

Just want to know if we can have an official statement about this.

It is safe, from iOS 15.4 onwards, to use UserDefaults and access Keychain in the didFinishLaunchingWithOptions app delegate method?

Thank you

There is lots of good info in this SO question, particularly this answer, and the linked tweet.

Quoting that:

Apple's documentation is incorrect, here is the behaviour observed on iOS 15:

UIApplicationMain() always runs, including during prewarming.

What happens after this depends on whether your app uses the UIScene life-cycle.

  • For apps that do support scenes:

    • application:didFinishLaunchingWithOptions: may be called (doesn't always happen)
    • scene:willConnectToSession:options: is not called - in fact the SceneDelegate is not created until the app is opened.
  • For apps that do not support scenes:

    • application:didFinishLaunchingWithOptions: is not called.

I saw a lot of mentions in different threads and stackoverflow that if the app doesn't support scenes, didFinishLaunchingWithOptions shouldn't be called, DTS Enginner on this Thread said that after late iOS 15, didFinishLaunchingWithOptions definitely won't be called during prewarming. But we still see in our logs that didFinishLaunchingWithOptions is called during prewarming, even on iOS 18. We don't support scenes, and our AppDelegate is completely Objective-C(I saw some answers that might be relevant).

iOS 15 prewarming and didFinishLaunchingWithOptions
 
 
Q