Could not find a storyboard named 'Main' in bundle

前端 未结 24 1420
无人共我
无人共我 2020-12-01 00:26

I\'m getting a strange error: \'Could not find a storyboard named \'Main\' in bundle NSBundle\' when trying to run my app on a real iOS device.

I have

相关标签:
24条回答
  • 2020-12-01 01:03
    1. Open you storyboard file
    2. Then Click File Inspector
    3. Then select "Target Membership" and check your project
    4. Do the same for ViewController file !!!important part if you use ViewController.swift or ViewController.m with your storyboard!!!
    0 讨论(0)
  • 2020-12-01 01:05

    If still you have black screen, then try adding below code in your scene delegate

    willConnectTo

        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        let navController = UINavigationController()
        let mainstoryboard:UIStoryboard = UIStoryboard(name: "Your storyboard name", bundle: nil)
        let initialController = mainstoryboard.instantiateViewController(withIdentifier: "your initial controller Identifier") as! initialController
        navController.addChild(initialController)
        window?.rootViewController = navController
        window?.makeKeyAndVisible()
    
    0 讨论(0)
  • 2020-12-01 01:07

    I was moving Main.Storyboard file to "blue" sub folder which was causing issues, I had to add sub folders following these instructions Xcode 6.3 New File Issue

    then moving Main.Storyboard file to yellow sub folder did work for me

    0 讨论(0)
  • 2020-12-01 01:09

    Swift 5.1 & xCode 11.2

    In my case, I forgot to change Storyboard Name in Info.plist

    Info.plist source code

        <dict>
            <key>UIApplicationSupportsMultipleScenes</key>
            <false/>
            <key>UISceneConfigurations</key>
            <dict>
                <key>UIWindowSceneSessionRoleApplication</key>
                <array>
                    <dict>
                        <key>UISceneConfigurationName</key>
                        <string>Default Configuration</string>
                        <key>UISceneDelegateClassName</key>
                        <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
                        <key>UISceneStoryboardFile</key>
                        <string>AccountViewController</string>
                    </dict>
                </array>
            </dict>
        </dict>
    
    0 讨论(0)
  • 2020-12-01 01:16

    Follow the steps:

    1) First Click your story board

    2) Then Click File Inspector

    3) Then select "Target Membership"

    0 讨论(0)
  • 2020-12-01 01:17

    I deleted the app from my phone, did Product-->Clean, and loaded it again. That's all it took for me.

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