SwiftUI - main(), Scene and WindowGroup are only available in iOS 14 or newer

5.9k Views Asked by At

I started a SwiftUI project with iOS 15 as a deployment target, I was asked to lower the version, so I changed it to iOS 13, after resolving some code compatibility issues I was left with an error at the entry point of the app MyProjectApp.swift saying that main() and Scene and WindowGroup are ONLY available for iOS 14+

How can I make the Entrypoint compatible with versions lower than iOS 14.x ?

this is this code for my Entry point

@main //'main()' is only available in iOS 14.0 or newer
struct MyProjectApp: App {
        let persistenceController = PersistenceController.shared
        var body: some Scene { //'Scene' is only available in iOS 14.0 or newer
            WindowGroup { //'WindowGroup' is only available in iOS 14.0 or newer
                ContentView()
            .environment(\.managedObjectContext, persistenceController.container.viewContext)
        }
    }
}
0

There are 0 best solutions below