TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.