How to Migrate Your Project from SwiftUI 1.0 to SwiftUI 2.0 (Or from Xcode 11.x to 12.x)

Mark Moeykens
Jul 4, 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.

I get a blank screen (all black, usually)
I've gotten this before too. I even set breakpoints in my new App file and it doesn't even break.

What worked for me was deleting the app from the device/simulator I was using and installing a fresh app.


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.

Free SwiftUI Picture Book

8 comments

Simone Girardi
Jul 4, 2020
Thanks! 🙂🙏🏻
Mark Moeykens
Jul 13, 2020
You're welcome!
Jeff Grann
Oct 11, 2020
Trying this out and I'm getting a blank screen in Simulator. I even tried creating a new project from scratch (with CoreData which my project uses) while making no changes at all and it displays a blank screen in Simulator too. Not sure how to debug this since I'm not getting any build errors or errors in the console.
Jeff Grann
Dec 28, 2020
No, I haven't. I put it on the back burner. As I said in my original post, I tried creating a new, simple test project from scratch with CoreData enabled and I still got a blank screen in the simulator and on my real device. Have you tried it with CoreData? BTW, thank you so much for your excellent SwiftUI resources!!
David Koontz
Jan 3, 2021
I'm wondering what I'm missing... getting: "...App" is annotated with @main and must provide a main static function of type() -> Void or () throws -> Void. Inheritance from non-protocol type 'App' errors in Xcode Set the Deployment Info to iOS 14.3 wrote a new MyApp.swift file: import SwiftUI @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } }
David Koontz
Jan 3, 2021
Using XCode 12.3 found: https://stackoverflow.com/questions/63971819/ios-xcode-12-0-swift-5-appdelegate-is-annotated-with-main-and-must-provide-a but switching out @main to @UIApplicationMain didn't work. switching struct to class - no luck... I'm just stabing in the dark.