How to Migrate Your Project from SwiftUI 1.0 to SwiftUI 2.0 (Or from Xcode 11.x to 12.x)
July 04, 2020
I wanted to migrate my SwiftUI project to use the new App protocol as you see here:

import SwiftUI

@main
struct TestApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Here are the steps I took and the mistakes I made along the way.

File to Add

Add a new file that will hold the code for your struct to conform to the App protocol.

Warning: Do not name the new struct the SAME name as your project.

Although your project will run fine, your previews on the canvas will throw an error and not render. The error being:

Compiling failed: '[File]' is not a member type of '[project name]'

Just append the word "App" to your struct name to be safe.

Files to Delete

  1. AppDelegate
  2. SceneDelegate
  3. LaunchScreen.storyboard

Info.plist Changes




  1. Delete the Scene Configuration under Application Scene Manifest.
  2. Delete "Launch screen interface file base name" key.
  3. Delete "Main storyboard file base name" key.
  4. Add "Launch Screen" key.

OK, that should be it! Be sure to set your starting view in the App file and run your project.



Common Errors


My screen looks weird
When you ran your project, did it look like this:



If so, then you forgot to do step 4 when making changes to your Info.plist. This key doesn't require a value but if the key is not added, it'll make your screens look funny.

Build Errors
"Entry point (_main) undefined. for architecture x86_64"
Solution: Add @main to the beginning of your struct that implements the App protocol (see example at top of post).

"'Scene'/'WindowGroup'/'main()' is only available in iOS 14.0 or newer"
Solution: Change your deployment info so your project targets iOS 14.0 or higher.
2 comments
Write a comment...
Simone Girardi

Thanks! 🙂🙏🏻

Mark Moeykens

You're welcome!

Explorer

Free
Gain exclusive access to Big Mountain Studio 
  • News
  • Tutorials
  • Updates, etc.
When signed up, you get posts delivered right to your Inbox!
Includes access to 1 product:
Get access