So, basically I'm trying to apply a modifier that is only available for macOS 13, while my app targets macOS 11+
Here's a piece of code that defines the macOS app with a WindowGroup
var body: some Scene {
WindowGroup {
MainView(viewModel: viewModel)
.frame(minWidth: 420.0, maxWidth: 420.0, minHeight: 600.0, maxHeight: 600.0)
}
.windowStyle(HiddenTitleBarWindowStyle())
}
I would like to add this to the WindowGroup:
.windowResizability(.contentSize)
Is there a way to do this? Any approach I try, even a straight-forward one below results in a "Closure containing control flow statement cannot be used with result builder 'SceneBuilder'" build error
var body: some Scene {
if #available(macOS 13.0, *) {
WindowGroup {
MainView(viewModel: viewModel)
.frame(minWidth: 420.0, maxWidth: 420.0, minHeight: 600.0, maxHeight: 600.0)
}
.windowResizability(.contentSize)
.windowStyle(HiddenTitleBarWindowStyle())
} else {
WindowGroup {
MainView(viewModel: viewModel)
.frame(minWidth: 420.0, maxWidth: 420.0, minHeight: 600.0, maxHeight: 600.0)
}
.windowStyle(HiddenTitleBarWindowStyle())
}
}
Thanks for any suggestions
You can do something like this:
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(HiddenTitleBarWindowStyle())
.myWindowIsContentResizable()
}
extension Scene {
func myWindowIsContentResizable() -> some Scene {
if #available(macOS 13.0, *) {
return self.windowResizability(.contentSize)
}
else {
return self
}
}
}