I try Control Widget I check API availability like this
don't work WidgetBundleBuilder.buildBlock() so i use ControlWidgetConfigurationBuilder.buildBlock ! but it didn't work too
what should i do ?
Would something like this format help?
import WidgetKit
import SwiftUI
@main
struct AppWidgets {
// Combine widgets in this way to prevent crashes.
static func main() {
if #available(iOSApplicationExtension 18.0, *) {
WidgetsBundle18.main()
} else {
WidgetsBundle17.main()
}
}
}
@available(iOSApplicationExtension 18.0, *)
struct WidgetsBundle18: WidgetBundle {
var body: some Widget {
NewWidget()
}
}
struct WidgetsBundle17: WidgetBundle {
var body: some Widget {
OldWidget()
}
}