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

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

    In my case, it was a storyboard inside a framework for a Mac application. I was using:

    let storyboard = NSStoryboard(name: "StoryboardName", bundle: nil)
    

    and needed to use the framework's bundle identifier to get the correct bundle:

    let storyboard = NSStoryboard(name: "StoryboardName",
                                bundle: Bundle(identifier: "com.company.FrameworkName"))
    
    0 讨论(0)
  • 2020-12-02 16:09

    I had my app working normally on the iPhone Simulator but strangely Xcode stopped responding and i had to Force Quit Xcode. When I restarted Xcode i encountered "Could not find a storyboard named MainStoryboard....",

    I have fixed this issue by following below steps:

    1. Renaming "MainStoryboard.storyboard" to "MainStoryboard_1.storyboard"
    2. Open file "$your_app$-Info.plist" located in "Supporting Files" folder. Edit "Main storyboard file base name" to "MainStoryboard_1.storyboard".
    3. Rerun the app, and it worked for me.
    4. I renamed my storyboard file back to its original "MainStoryboard.storyboard".
    5. Edited the .plist file back to its original.
    6. Rerun the app, and it worked for me.

    For some reason the file "MainStoryboard.storyboard" was not recognised after force quitting Xcode and following above steps made the app recognise the file back again.

    Hope this solution helps..

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

    A very silly one but I had "MainStoryboard.storyboard" in the "Main storyboard file base name (iPad)" entry of my my .plist instead of just "MainStoryboard".

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

    This happened to me when I had a previous app with the same name installed on the simulator.

    I have removed the previous app, re-selected the Storyboard on the "Deployment Info", re-run the app, and everything worked fine.

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

    A simple Clean corrected the error for me.

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

    I thought you may have deleted the storyboard and decided to use a .xib file on initial app launch. In this scenario, Xcode would try to find a nonexistent storyboard.

    For this case, click on the Project > Info > Custom iOS Target Properties and delete this key value pair: Main storyboard file base name

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