iOS 7 - Failing to instantiate default view controller

前端 未结 16 1883
一生所求
一生所求 2020-11-28 03:08

I am using Xcode 5 in a newly created app and when I just create it I go for the run button e click on it, then the project gets built but it does not show in the iOS Simula

相关标签:
16条回答
  • Projects created in Xcode 11 and above, simply changing the Main Interface file from the project settings won't be enough.

    You have to manually edit the Info.plist file and set the storyboard name for the UISceneStoryboardFile as well.

    0 讨论(0)
  • 2020-11-28 03:45

    Check if you have the window var in the AppDelegate.

    var window: UIWindow? 
    

    And also check the storyboard of your Info.plist file.

    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    

    Programmatically setting the rootViewController in the AppDelegate is not going to fix the warning. You should choose whether to let to the storyboard set the view controller or do it programmatically.

    0 讨论(0)
  • 2020-11-28 03:47

    So this also happened to me too. I checked 50 times and my "Is Initial View Controller" was checked, believe me. It happened out of the blue. So how did I fix it?

    1. Create a new Storyboard in your project, name it something like Main_iPhoneV2 (or iPadV2 depending on your original storyboard style)
    2. Open the broken storyboard, click anywhere in the white area and press command-a, then command-c (select all and copy)
    3. Open your new storyboard and press command-v to paste the same exact setup
    4. Go to your project settings, change your "Main Interface" to the new Main_iPhoneV2 (If it's your iPad and you're writing a universal app, you'll have to edit the -Info.plist and look for the value "Main storyboard file base name (iPad)
    5. Recompile, and stop pulling your hair out
    0 讨论(0)
  • 2020-11-28 03:48

    If you added new storyboard then you have to check following points.

    1) In your plist file check value of Main storyboard file base name (iPad) or (iPhone) should be matched with your storyboard file name (do not add extension .storyboard)

    2) In storyboard there should be one view controller which set as Is initial view controller

    3) Clean and build your project. :)

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