I’m using the new DocumentGroupLaunchScene introduced in iOS 18.0 in my document-based SwiftUI app like this:
@main
struct MyApp: App {
var body: some Scene {
DocumentGroup(newDocument: MyDocument()) { file in
ContentView(document: file.$document)
}
if #available(iOS 18.0, *) {
DocumentGroupLaunchScene {
NewDocumentButton("Start")
} background: {
Color.blue
}
}
}
}
When I run my app on a device with iOS 17 it crashes with this error:
Fatal error: if #available in SceneBuilder includes an unknown OS version
How can I use DocumentGroupLaunchScene while still supporting older iOS versions?
2
Answers
I managed to fix this crash by implementing two App structs:
It seems like in iOS 18.1, they fixed the issue: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-18_1-release-notes