Creating a new Xcode project without Storyboard in Xcode 14

By default when you create a Xcode project, it lets you choose whether you want to create it in Storyboard or SwiftUI. If you choose storyboard, it will automatically create a storyboard for you in Xcode 14.

In order to remove the storyboard, you would need to do the following

  1. Delete the Main.storyboard file.

2. Go to Targets -> Select your target -> Click on the Info tab
3. Delete the row Main Storyboard file base name

4. Expand Application scene manifest. Drill down and delete the row Storyboard name.

5. Open SceneDelegate class and update the code in the following method

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }
    }
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let windowScene = (scene as? UIWindowScene) else { return }
          
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = ViewController() // Your initial view controller.
            window.makeKeyAndVisible()
            self.window = window
    }

6. Run the code, you should be able to run the new view controller.

In

Leave a Reply

Your email address will not be published. Required fields are marked *