How to make an optional widget in Swift? WidgetBundle uses @resultBuilder, so I think we can do something similar to SwiftUI:
// SwiftUI example
if showText {
Text("Optional text")
}
And here's what I want to get working:
struct MyWidgetBundle: WidgetBundle {
let enableTestWidget: Bool = ...
// Compile error: Failed to produce diagnostic for expression;
// please submit a bug report (https://swift.org/contributing/#reporting-bugs)
var body: some Widget {
Widget1()
Widget2()
if enableTestWidget {
TestWidget()
}
}
}