iOS widget always displaying placeholder on simulator or device

I'm made an very basic iOS Widget Extension with (on iOS 16):

struct TotoView: View 
    var body: some View {
        VStack {
            Text("Toto")
                .font(.headline)
        }
    }
} 

On the SwiftUI Canvas preview, I can see the "Toto" text.

BUT when I select the Widget Target and run in the simulator, I only have the placeholder in place of text. Any idea of why?

Note that I think the issue happen when the view is used in an IntentConfiguration (and everything works fine when used in StaticConfiguration).

Note that I'm on xCode 14. Could it be an Apple issue?

Are you seeing the placeholder representation in the widget on the Home Screen (or the Lock Screen) after you've added it, or when you're about to add it?

Here's the comments I have in the various methods in my IntentTimelineProvider:

func placeholder(in context: Context) -> EventEntry {
		// When WidgetKit displays your widget for the first time, it renders the widget's view as a placeholder, which displays a
		// generic representation of your widget, giving the user a general idea of what the widget shows. WidgetKit calls this
		// method to request an entry representing the widget's placeholder configuration. In addition, WidgetKit may render your
		// widget as a placeholder if the user chooses to hide sensitive information on Apple Watch.

		// For the placeholder, the system automatically redacts all of the widget's content, unless you explicitly mark items with the
		// unredacted() view modifier in your widget's SwiftUI view. As a result, you may want to provide generic data that fills
		// out the redacted version.
...
}

func getSnapshot(for configuration: DynamicEventSelectionIntent, in context: Context, completion: @escaping (EventEntry) -> Void) {
		// For the snapshot, return a single entry. In general, you want to return the current state of your app.
		// However, the system also uses the snapshot when displaying your widget in the widget picker.
...
}

Maybe your content is taking too long to be delivered and displayed? Or perhaps your content needs the .unredacted() modifier on it?

It has happened to me a couple of times.

Possible causes:

1 It takes a long time for the timeline provider function to provide a timeline.

  • If that is the case then reduce the number of timeline entries and have a reload policy of atEnd

2 Sometimes this happens when using Running the app on device vs TestFlight app version.

  • Delete app and restart phone and install app and then add the accessory widget.

With static configuration, widget extensions work for my app with some families (circular, rectangular), remain blank with some families (corner, inline) on watch. Always show place holders on iPhone.

iOS widget always displaying placeholder on simulator or device
 
 
Q