Reputation:
I am working on a SwiftUI app that still has the Scene / App Delegate files and would like to migrate it to the new SwiftUI App Protocol.
Is this only a matter of deleting the Scene / App Delegate files, then adding my ContentView (Initial View in my case) to the @main struct???
Thank you!
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Upvotes: 13
Views: 4045
Reputation: 54516
You need to follow these steps to migrate a SwiftUI application to the new App
life cycle:
App
struct and add the @main
annotation:@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Remove the @main
annotation from AppDelegate
.
Remove Scene Configuration
from Info.plist
:
AppDelegate
/SceneDelegate
methods:Now you can remove the AppDelegate
and SceneDelegate
classes from the project (first make sure the app is indeed working as expected).
Reinstall the app (as suggested in the comments).
Upvotes: 24