【问题标题】:Xcode 11 Could not find a storyboard named 'Main' in bundle NSBundleXcode 11 在捆绑包 NSBundle 中找不到名为“Main”的情节提要
【发布时间】:2019-10-16 05:13:12
【问题描述】:

之前有人问过这个问题,但我的问题是 Xcode 11 和 UISceneConfiguration。在 Xcode 11 之前,当您从目标中删除故事板 (Main.storyboard),然后添加新故事板 (AnotherStoryboard.storyboard) 时,您必须更新 Targets > General > Deployment Info > Main Interface 才能使用新添加的故事板。在 Xcode 11 中,这还不够,应用会抛出异常

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Could not find a storyboard named 'Main' in bundle NSBundle

我发现的问题是,在 Info.plist 中,现在有一个名为 UIApplicationSceneManifest 的新键,其中有一个嵌套的 UISceneStoryboardFile,当您更改目标中的主界面时,它正在更新。但是,在Info.plist 的顶层仍然有一个UIMainStoryboardFile 键,它拥有旧的“主要”情节提要的标题。长话短说,如果您删除UIMainStoryboardFile,该应用程序将运行良好。

我的问题:这是 Xcode 11 中的错误,还是我遗漏的其他东西可以防止这种情况发生?当我尝试调试它并最终自己解决时,我并没有真正找到任何有用的东西。

【问题讨论】:

    标签: ios swift xcode storyboard xcode11


    【解决方案1】:

    在你的info.plistMain文件中设置了Scene Configuration,所以它总是找到那个文件并抛出异常。您可以通过编程方式设置默认 ViewController。在您的info.plist 中将Scene Configuration 设置为Default configuration 并选择无进入Targets > General > Deployment Info > Main Interface

    你的sceneWillConnectTo就像

      window = UIWindow(frame: UIScreen.main.bounds)
      window!.windowScene = windowScene
      window!.rootViewController = //your homeVC
      window!.makeKeyAndVisible()
    
    

    【讨论】:

      【解决方案2】:

      在你的 info.plist 中你必须设置这个属性 应用场景清单 -> 场景配置 -> 应用会话角色 -> 项目 0 -> 故事板名称

      Info.plist

      【讨论】:

      • 如果在项目中添加了重复的目标,那么新创建的信息列表应该通过相应的故事板名称进行更新。如上所述。
      猜你喜欢
      • 2014-11-02
      • 1970-01-01
      • 1970-01-01
      • 2013-10-14
      • 2015-04-29
      • 2016-05-29
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多