xcode 无法加载 nib 文件:MainWindowController.xib,正在退出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20202398/
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
Unable to load nib file: MainWindowController.xib, exiting
提问by Abdullah Shafique
I just created my first Mac Application but the program keeps crashing with this message:
我刚刚创建了我的第一个 Mac 应用程序,但程序不断崩溃并显示以下消息:
Unable to load nib file: MainWindowController.xib, exiting
Unable to load nib file: MainWindowController.xib, exiting
All I did was delete MainMenu.xib and created MainWindowController.xib and added it as the MainInterface.
我所做的只是删除 MainMenu.xib 并创建 MainWindowController.xib 并将其添加为 MainInterface。


回答by Brad Allred
This error is caused by the nib/xib missing at runtime when NSApplicationtries to load what it is told is the main interface nib. In most cases it stems from accidentally removing the nib from the "Copy Bundle Resources" build phase for your application target. For other (non main nibs) it can also be caused by typos when typing the nib name.
这个错误是由于在NSApplication尝试加载它被告知是主界面 nib时在运行时缺少 nib/xib 引起的。在大多数情况下,它源于不小心从应用程序目标的“复制捆绑资源”构建阶段中删除了笔尖。对于其他(非主要笔尖),输入笔尖名称时也可能由拼写错误引起。
In this specific case, however, I have determined that selecting the "main interface" from the dropdown menu in the target properties section is bugged. You have to delete the ".xib" extension from it for it to work correctly; so manually type MainWindowControllerinstead of the MainWindowController.xibthat you selected.
但是,在这种特定情况下,我确定从目标属性部分的下拉菜单中选择“主界面”是有问题的。您必须从中删除“.xib”扩展名才能正常工作;所以手动输入MainWindowController而不是MainWindowController.xib你选择的。
With the ".xib" extension in the "Main Interface" box, NSApplicationwill erroneously attempt to load MainWindowController.xib.xib
使用“主界面”框中的“.xib”扩展名,NSApplication将错误地尝试加载MainWindowController.xib.xib
回答by user7234769
Just cleaning and building again is what worked for me.
只是清洁和重新建造对我有用。

