9

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)
        }
    }
}
Thorvald
  • 3,424
  • 6
  • 40
  • 66
  • 2
    Does this answer your question https://stackoverflow.com/questions/62935053/use-main-in-xcode-12? – Asperi Nov 10 '21 at 11:02
  • @Asperi unfortunately that does not answer it, the project is in SwiftUI, I do not have AppDelegate and the files included in a Storyboard project – Thorvald Nov 10 '21 at 11:34
  • 1
    The answer(s) linked to above shows the exact steps for how to achieve this. You don’t have an app delegate or storyboard files right now, but the answers detail what files to add, which you will need to do manually. – jnpdx Nov 10 '21 at 14:11

0 Answers0