SceneDelegate without storyboard

As a backend engineer, I do not want to use storyboard/nibs/xibs, for reasons.

Step 1. Delete Main.storyboard in Xcode.

and confirm Move to trash:

Step 2. If you run the app now, it crashes at start up:

This is because we removed the Main.story file, and now iOS does not know how to launch the first screen for the app. Source code

So there are additional steps to change the project meta data.

Step 3. Remove Main Interface.

  1. Toggle Navigator
  2. Toggle Project
  3. Select project
  4. Select TARGETS
  5. Select General
  6. Select Main Interface and delete the text Main.

Step 4. Remove related Info. Source code

Similar to Step 3, but select Info instead of General.

Application Scene Manifest
-> Scene Configuration
-> Application Session Role
-> Item 0
-> Storyboard Name
-> Click ‘-’ to delete it

Step 5. Now the app runs without a crash. But it is just a black screen, because there is nothing for the app to show. The starting point of an iOS13 app is the SceneDelegate.swift file. Add the code into the scene function, then the app runs with a yellow screen. Source Code Diff.

guard let windowScene = (scene as? UIWindowScene) else { return }window = UIWindow(frame: UIScreen.main.bounds)window?.windowScene = windowScenewindow?.rootViewController = ViewController()    // In ViewController.swiftwindow?.rootViewController?.view.backgroundColor = .yellow  // So we can see itwindow?.makeKeyAndVisible()



Originally published at on November 10, 2019.