I found a simple answer here: https://stackoverflow.com/questions/74300019/how-to-use-if-available-in-main-in-a-documentgroup-application
Just enclose in a func:
struct TheApp: App {
var body: some Scene {
conditionalScene()
}
#if os(macOS)
func conditionalScene() -> some Scene {
if #available(macOS 13.0, *) {
WindowGroup {
ContentView()
.frame(
minWidth: 1200, maxWidth: .infinity,
minHeight: 600, maxHeight: .infinity)
}
.windowResizability(.contentSize) // Only here
} else {
WindowGroup {
ContentView()
.frame(
minWidth: 1200, maxWidth: .infinity,
minHeight: 600, maxHeight: .infinity)
}
}
}
#else // iOS
func conditionalScene() -> some Scene {
if #available(iOS 17.0, *) {
WindowGroup {
ContentView()
.frame(
minWidth: 1200, maxWidth: .infinity,
minHeight: 600, maxHeight: .infinity)
}
.windowResizability(.contentSize) // Only here
} else {
WindowGroup {
ContentView()
.frame(
minWidth: 1200, maxWidth: .infinity,
minHeight: 600, maxHeight: .infinity)
}
}
}
#endif // test of OS
} // App