Ok, i’m lost with this one. I have a widget bundle and i need to have different widgets for different versions of iOS. Can someone explain to me why the following code works fine, but if I uncomment those 2 lines it starts giving me a Function declares an opaque return type 'some Widget', but the return statements in its body do not have matching underlying types error?
@main
struct MyWidgetsBundle: WidgetBundle {
var body: some Widget {
if #available(iOS 17.0, *) {
return WidgetBundleBuilder.buildBlock(
A(),
B(),
C(),
D()
)
} else if #available(iOS 16.1, *) {
return WidgetBundleBuilder.buildBlock(
// A(),
// B(),
C(),
D1(),
D2()
)
} else {
return WidgetBundleBuilder.buildBlock(
C(),
D1(),
D2()
)
}
}
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: