Could not find a storyboard named 'MainStoryBoard' in bundle NSBundle

前端 未结 27 2685
感动是毒
感动是毒 2020-12-02 15:41

I have started a new app a few days ago and began working with the simulator to test it. I started as an empty project and manually added the storyboard. The simulator build

27条回答
  •  时光说笑
    2020-12-02 16:15

    Update: Swift 5 and iOS 13:

    1. Create a Single View Application.
    2. Delete Main.storyboard (right-click and delete).
    3. Delete Storyboard Name from the default scene configuration in the Info.plist file:
    4. Open SceneDelegate.swift and change func scene from:
    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 }
    }
    

    to

     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).x
    
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = ViewController()
            self.window = window
            window.makeKeyAndVisible()
        }
    }
    

    Now you are good to go :)

提交回复
热议问题