When I was developing the visionOS 26beta Widget, I found that it could not work normally when the real vision OS was running, and an error would appear.
Please adopt container background api
It is worth mentioning that this problem does not occur on the visionOS virtual machine.
Does anyone know what the reason and solution are, or whether this is a visionOS error that needs Feedback? Thank you!
The simulator has an issue where it doesn't raise this error. Widgets do require this background to work. Here is an example from one of mine. You will need to add containerBackground
to the view.
struct EmojiWidget: Widget {
let kind: String = "EmojiWidget"
var body: some WidgetConfiguration {
AppIntentConfiguration(kind: kind, intent: EmojiConfigurationAppIntent.self, provider: EmojiProvider()) { entry in
EmojiWidgetEntryView(entry: entry)
.containerBackground(.white.gradient, for: .widget)
}
.supportedFamilies([.systemLarge])
.supportedMountingStyles([.elevated, .recessed])
.widgetTexture(.paper)
.configurationDisplayName("Emoji Circle")
.description("Adjust the number of emojis in a radial layout")
}
}
You can optionally make this removable (let the system replace it with other backgrounds) by adding this
AppIntentConfiguration{...}
.containerBackgroundRemovable(false)