UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to migrate from SceneDelegate to the new main App struct?

Forums > SwiftUI

What's the correct approach of migrating an old swiftUI app using SceneDelegate to the new @main App protocol?

Can you simply delete the AppDelegate and SceneDelegate and create the new App struct? Do you need to change anything in the build settings or plist to get this to work?

It would be great to have a video dedicated to the new App protocol and how to migrate from SceneDelegate!

3      

Basically, yes. If you have Core Data, however, I don't think Xcode has a @main-style template for that yet. This Apple Developer Forum post is a good solution until Apple officially recommends one.

4      

I did migrate one of my projects from the old SwiftUI to the new @main SwiftUI App.

I did simply delete AppDelegate and SceneDelegate and inject my custom NSPersistentCloudKitContainerClass into the environment in the @main SwiftUI App.

It worked perfectly fine for me. (The answer to above linked Apple Developer Forum post is from me :-) and the recommendation on the merge policy from the apple engineer worked also fine)

But my project was a relative simple without any custom code in SceneDelegate and AppDelegate. If you have custom code there you probably need to figure out where to move it before deleting it.

4      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.