SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)

I have a question regarding cold start and pre-warming behavior on iOS.

I’m developing a SwiftUI app that continuously receives data from a BLE device in the background. We’ve observed that after the BLE stream stops, the OS often terminates our app. Later, when the sensor comes back into range, iOS appears to relaunch (or reinitialize) the app.

In our app, we use a WindowGroup like this:

WindowGroup {
    AppView(store: store)
}

We’ve placed our BLE reconnection logic inside a .task modifier in AppView.

What’s confusing is this:

  • Most of the time, when the app is relaunched, AppView is created and the .task runs as expected.
  • However, in about 1 out of 10 cases, AppView is not created at all, so the .task does not execute.

I’m trying to understand:

  • Under what conditions does iOS relaunch an app without fully initializing the SwiftUI view hierarchy?
  • Is this related to pre-warming or background relaunch mechanisms (e.g., CoreBluetooth state restoration)?
  • What determines whether the WindowGroup and root view are actually instantiated?

Any insight into the system’s relaunch behavior or lifecycle in this scenario would be greatly appreciated.

SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)
 
 
Q