Search code examples
iosswiftuixcode-storyboard

Main.storyboard showing black screen


I created an Xcode ios project. I choose the SwiftUI for the user interface. At a later stage, I decided to use Storyboard instead.

  1. So created a new storyboard.
  2. Added View Controller as an initial view controller
  3. Changed the SceneDeligate scent to return guard let _ = (scene as? UIWindowScene) else { return } instead of SwiftUI instance creation code.
  4. Added Main in Info.plist as the Main storyboard.

When I run the app after above changes black screen appears after showing launch screen.


Solution

  • When working with Scenes, you need to specify the starting storyboard in a different place in the Info.plist, under

    • Application Scene Manifest
      • Scene Configuration
        • Application Session Role
          • Item 0
            • Storyboard Name (this key needs to be added manually)

    Unfortunately, this can only be done directly by editing the Info.plist, not in the target settings / deployment info section:

    Info.plist

    And don't forget to set the initial view controller in the storyboard:

    IsInitialViewController