xcode “在捆绑 NSBundle 中找不到名为‘MainStoryboard’的故事板”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15951716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:11:15  来源:igfitidea点击:

"Could not find a storyboard named 'MainStoryboard' in bundle NSBundle"

iosobjective-cxcode

提问by Michael

I've been working on a application for a long time now and out from the blue i got this:

我已经在一个应用程序上工作了很长时间,突然间我得到了这个:

"Could not find a storyboard named 'MainStoryboard' in bundle NSBundle"

“在捆绑 NSBundle 中找不到名为‘MainStoryboard’的故事板”

I've red the similar questions here on StackOverflow and i tried everything including: - Renaming the storyboard file - Re-adding the storyboard file - Cleaned the project - Reset contents and setting on the simulator

我在 StackOverflow 上提出了类似的问题,我尝试了所有方法,包括: - 重命名故事板文件 - 重新添加故事板文件 - 清理项目 - 重置模拟器上的内容和设置

I've also checked the plist file and the Copy Bundle Resources and the storyboard name is as it should be. Nothing of this works.

我还检查了 plist 文件和 Copy Bundle Resources,故事板名称应该是这样。这一切都不起作用。

I'm developing the application with a friend and we are using Git. The weird thing is that the same version works just fine for him.

我正在和一个朋友一起开发应用程序,我们正在使用 Git。奇怪的是,相同的版本对他来说效果很好。

However, in the Copy Bundle Resources the MainStoryboard.storyboard and InfoPlist.strings are red. But they have been red for a long time without any troubles. And my friend (for which the project works fine) they are also red.

但是,在 Copy Bundle Resources 中,MainStoryboard.storyboard 和 InfoPlist.strings 是红色的。但他们已经红了很长时间没有任何麻烦。我的朋友(项目运行良好)他们也是红色的。

enter image description here

在此处输入图片说明

Ideas?

想法?

回答by MonsieurDart

I would suggest to check that this file is not localized (with no actual localization), to remove the localization and to re-add the file.

我建议检查此文件是否未本地化(没有实际本地化),删除本地化并重新添加文件。

If this does not work, have you tried to clone a fresh copy of the project from Git?

如果这不起作用,您是否尝试过从 Git 克隆项目的新副本?

回答by x4h1d

  • Select the MainStoryboard.storyboard, from under the project, located in the left panel of the XCode
  • Click the File inspector, on the right side of the XCode.
  • Check the box for Project Targetunder Target Membership.
  • Do the same for infoplist.strings
  • Clean the project and run it.
  • 从位于 XCode 左侧面板的项目下选择MainStoryboard.storyboard
  • 单击XCode 右侧的文件检查器
  • 选中Target Membership下的Project Target框。
  • infoplist.strings做同样的事情
  • 清理项目并运行它。

OR

或者

  • Remove the files from Copy Bundle Resources
  • Add those two file by clicking +sign.
  • Clean the project and run it.
  • 复制捆绑资源中删除文件
  • 单击+号添加这两个文件。
  • 清理项目并运行它。

回答by cate

For what it's worth, I've just had this problem with a fresh project in Xcode 5, trying to set the deployment target back to 5.0. The empty Utility Application would start up fine on simulator on iOS 6+, but would crash with above warning on iOS 5.0/5.1.

对于它的价值,我刚刚在 Xcode 5 中的一个新项目中遇到了这个问题,试图将部署目标设置回 5.0。空的实用程序应用程序可以在 iOS 6+ 上的模拟器上正常启动,但在 iOS 5.0/5.1 上会因上述警告而崩溃。

Selecting the storyboard in the Project Navigator and File Inspector tab, I found the 'English' icon was plain and unchecked. I checked it:

在“项目导航器”和“文件检查器”选项卡中选择故事板,我发现“英语”图标很简单且未选中。我查了一下:

enter image description here

在此处输入图片说明

then clicked on 'Localizable strings', whence I got an alert: enter image description here

然后单击“可本地化的字符串”,从那里我收到警报: 在此处输入图片说明

After converting, File Inspector looks like this:

转换后,文件检查器如下所示:

enter image description here

在此处输入图片说明

and the app no longer crashes. The Project Navigator now shows both Base and English storyboards:

并且应用程序不再崩溃。项目导航器现在同时显示基础故事板和英语故事板:

enter image description here

在此处输入图片说明

I will leave to someone more knowledgeable to explain what's going on here and what are the consequences of losing the 'Localizable strings' in favour of a proliferation of storyboards...

我将让知识渊博的人来解释这里发生的事情,以及为了故事板的激增而丢失“可本地化字符串”的后果是什么......

回答by KAR

  1. Go to build phases in your app.
  2. click on 'Copy Bundle Resources'
  3. Find your main storyboard file if not than click on '+' icon in bottom and add your main storyboard file to it.
  4. Now run the project again.
  1. 转到在您的应用程序中构建阶段。
  2. 单击“复制捆绑资源
  3. 如果不是,请找到您的主故事板文件,然后单击底部的“ +”图标并将您的主故事板文件添加到其中。
  4. 现在再次运行该项目。