Lazy loading of iOS SwiftUI Widget

I am trying to create Widget, which does the following.

  1. User specifies his intent, triggering the Timeline.
  2. the Timeline returns an entry, with isLoading Flag for the Widget View to render [IsLoading] View.
  3. in Background ( somehow ), the timeLine fetchs the real data via an API Call, and on its response, the timeline reloads the Widget View with the real data.

Implemented the Number 3, list above, via some programing logic, and calling reloadAllTimelines. This works sometimes, and fails other times.

Any help ?

The best first course of action here would be to use Console.app to monitor to the relevant processes related to your app and extensions.

A good way to start would be with filtering by the BundleID of the target and / or the target name itself (the process name).

Also be sure to check the system processes for additional information. This will vary based on what and where you are looking but some examples:
To debug APNS you'll want to monitor apnd along with other relevant processes.
To debug WidgetKit, LiveActivities, Dynamic Island you'll want to monitor springboardd, liveactivitiesd along with other relevant processes.

This may provide additional insight when your Widgets are not reloading.

Rico

WWDR - DTS - Software Engineer

Lazy loading of iOS SwiftUI Widget
 
 
Q