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

前端 未结 27 2569
感动是毒
感动是毒 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 :)

    0 讨论(0)
  • 2020-12-02 16:15

    The solution for me was, that I just needed to add the MainStoryboard to the Bundle Resources. After that, it works fine.

    Project -> Build Phases -> Copy Bundle Resources -> click on the + button and add your file.

    0 讨论(0)
  • 2020-12-02 16:16

    Go to your project, select your target and pull down from the menus to re-select your storyboards.

    Also, you can update your plist, I found that changing one did not change the other.

    0 讨论(0)
提交回复
热议问题