@surik92 and anyone else still struggling with this issue.
I was able to get some a response from Code Level Tech Support on this. I detailed our problems and referenced this post. I then asked for clarity.
We would love to get clarity here. We've read the documentation many times and it is our understanding that during prewarming the app should NOT execute the AppDelegate function application(_:didFinishLaunchingWithOptions:). If that is true, we shouldn't be seeing the issue given we only access UserDefaults in this method or later on in the life cycle. It appears (see forum post) we are not alone in this issue arising in iOS 15 while accessing Userdefaults in application(_:didFinishLaunchingWithOptions:).
Here is the response I received.
I can tell you from working with many Developers on this issue that if your app is getting pre-warmed then application(_:didFinishLaunchingWithOptions:) IS getting run. Now, this may be a bug or it may be intended behavior, the jury is still out on that item, but if you feel this is incorrect, I would open a bug report:
Based on this response our team has started to update our code to account for this. We will also be filing a bug with apple as the documentation and actual behavior, now confirmed by apple, are contradicting one another.
Post
Replies
Boosts
Views
Activity
I believe we have users experiencing issues due to UserDefaults.standard not providing the expected values. Our app does have data protection set to Complete.
We are accessing UseDefaults func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool . I am unclear if this is safe or not. Based on prepare your app for prewarming, I feel that we are far enough along that we should be okay?