Make sure you have the return keyword in front of iOS18Widgets and iOS17Widgets like
var body: some Widget {
if #available(iOSApplicationExtension 18.0, *) {
return iOS18Widgets
} else {
return iOS17Widgets
}
}
I only get the error if I remove the returns, as it treats the body as a builder that doesn't support control flow statements, but with the returns it works.