SwiftUI only showing a black screen

Also if the advice above didn't work, make sure that you have the correct pointer to SceneDelegate in your Info.plist.

Info.plist


In SceneDelegate.swift replace

let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()

with

if let windowScene = scene as? UIWindowScene {
    let window = UIWindow(windowScene: windowScene)
    window.rootViewController = UIHostingController(rootView: ContentView())
    self.window = window
    window.makeKeyAndVisible()
}

If you had a .environtmentObject attached to ContentView() originally, don't forget to add that onto the ContentView() in the above code.

When you create a new project in Xcode beta 4, the second code block I posted is what is automatically generated in SceneDelegate.swift. The first code block I posted is what was automatically generated in all versions prior to beta 4. As you can see in the second block, the window is now initialized with the scene provided by the SceneDelegate function scene(scene:, session:, connectionOptions:) instead of a CGRect (UIScreen.main.bounds).