Victor Wynne

WidgetBundle improvements in iOS 16.1

source: twitter.com

Luca Bernardi, who is part of the SwiftUI team at Apple:

Starting in iOS 16.1 (beta 2), WidgetBundle supports having if statement with #available clause (and only this specific clause) in its body.

That’s pretty useful to add more widget configurations that are supported only in later OSes like ActivityConfiguration.

This is the sample code he shared:

struct GrandPrixWidgets: WidgetBundle {
    var body: some Widget {
        NextRaceWidget ()

        if #available (iOS 16.1, *) {
           LiveRaceActivity()
        }
    }
}

👍🏻