iOS 13 UIWindowScene Black Screen

September 20, 2019

I've encountered this bug enough times that I figured it was time to write a quick post about it. If you've looked into multiple window support for your app in iOS 13, you might know that a lot of the setup you used to have to do in the app delegate now lives in the scene delegate instead.

However, multiple times now, I've thought I've set everything up correctly (scene delegate class implemented, configuration with delegateClass set properly, correct Info.plist setup, etc), only to get a black screen on launch.

The secret is this: prior to iOS 13, it was common to set up your UIWindow with the bounds of the screen:

// Does not work in iOS 13+
window = UIWindow(frame: UIScreen.main.bounds)

This breaks when using the UISceneSession system. Instead, you have to initialize the window with the scene itself, in your scene(scene:willConnectTo:options:) method:

window = UIWindow(windowScene: windowScene)

This has generally been the missing piece I forgot, and ends up resolving the black screen issue. Here's a concrete example.

Tweet This
Get New Posts Via Email
Picture of me with a corgi

Noah Gilmore

I'm Noah, a software developer based in the San Francisco Bay Area. I focus mainly on full stack web and iOS development

  • 💻 I co-founded Replo, a no-code platform for e-commmerce
  • ✍️ You can read technical posts on my blog
  • 📱 I wrote an app which lets you create transparent app icons called Transparent App Icons
  • 🧩 I made a puzzle game for iPhone and iPad called Trestle
  • 🎨 I wrote a CoreImage filter utility app for iOS developers called CIFilter.io
  • 👋 Please feel free to reach out on Twitter / 𝕏