无法在捆绑包中加载 NIB:“NSBundle”
下面列出的错误是什么?
2011-02-23 21:24:12.218 Success[7238:207] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在捆绑包中加载 NIB:”NSBundle < ;/Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (已加载)”,名称为“MainWindow-iPad”
What is the error listed below?
2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (loaded)' with name 'MainWindow-iPad''
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
项目中缺少一个 NIB 文件,请添加所需的 NIB 文件:
在“构建阶段”中
+
通过 Shift+Cmd+K 清理构建,然后运行。
PS 另外,请确保在调用
initWithNibName:@"ViewNameController"
时使用 NIB 文件的准确拼写,可能,您在通话中使用小写字母命名您的 NIB,或者您可能还添加了不需要的扩展名 .xib。
One of your NIB file is missing from project, add the required NIB file:
In Build Phases
+
at bottomClean your build by
Shift+Cmd+K
, then run.P.S. Also make sure to use exact spelling of NIB file while calling
initWithNibName:@"ViewNameController"
Probably, you have named your NIB in a call by lowercase letters or you may have also included extension .xib which is not required.
可能您在调用中用小写字母命名了您的 NIB。在这种情况下,模拟器工作正常,但 iPhone 设备将在运行时返回错误。
例如,
会失败。您需要更改为:
Probably, you have named your NIB in a call by lowercase letters. The simulator works fine in this case, but an iPhone device will return an error during runtime.
For example,
will fail. You need to change to:
在构建设置中,添加架构 =>> armv6 和 armv7
我刚刚使用这个删除了我的错误
In your Build Settings, Add Architecture =>> armv6 and armv7
I just removed my error using this
我遇到了同样的问题,但这是因为我写了扩展名 .xib 而不是必需
的
I have got the same problem, but it was because i wrote the extension .xib and it is not neccessary
instead of
就我而言,接下来是:
我加载了名为“??????Ipad”的代码 XIB
但 XIB 文件名是“??????iPad”
In my case was next:
I loaded in code XIB with name "??????Ipad"
but XIB filename was "??????IPad"
是否有与 NIB 相关的警告?这通常是针对 NIB 文件中的错误(例如 NIB 类型不正确)执行的。
右键单击该文件,然后单击“获取信息”以验证该类型是否符合您的预期。
Are there any warnings related to the NIB? This is usually do to an error in the NIB file (such as incorrect type of NIB).
Right click on the file and click "Get Info" to verify that the type is what you would expect.
另一个可能的问题:您正在使用iOS 5 上的基本本地化(注意,它在 iOS 模拟器上可以工作,但不能在设备上工作),但仅从 iOS 6 开始支持它。
了解更多信息,请参阅:无法在捆绑包基础国际化中加载笔尖
An other possible issue: you are using Base Localization on iOS 5 (caution, it kinda work on the iOS Simulator, but not on a device), but it is supported only starting from iOS 6.
For more info, see: Could not load nib in bundle base internationalization
请确保您的 nib/xib 文件包含在相应的目标会员资格中。
Please make sure your nib/xib file is included in the corresponding Target Membership.
我有同样的问题,只需按照步骤操作即可。
1.将您的项目复制到另一个地方。
2.复制崩溃应用程序的 NIB 文件。
3.只需更改名称
即可旧文件 Demo.xib 比复制并更改名称 DemoNew.xib
我的代码低于
旧代码,
我只是更改名称
,它对我有用。
I Have Same Problem Just Follow Steps.
1.Copy your Project In Another Place.
2.Copy your NIB File Which Crash app.
3.Just Change Name
Ex. Old File Demo.xib Than Copy And Change Name DemoNew.xib
My Code is Below
Old Code
I Just Change Name
its working for me.
只需检查您的项目中是否存在文件
MainWindow.xib
即可。如果没有,只需添加名为MainWindow.xib
的新界面文件。Just check that file
MainWindow.xib
exist in your project. If not, just add the new interface file with nameMainWindow.xib
.如果您尝试在从笔尖拾取的集合视图中加载collectionView单元,那么您可能会看到错误“'NSInternalInconsistencyException',原因:'无法在捆绑包中加载NIB:' NSBundle“
当您从 nib 文件加载集合视图时,您无法选择在 nib 上声明集合视图单元格,这与故事板不同。
正确的方法是使用新的笔尖创建一个新的自定义单元格,然后将其加载到集合视图中。
注意:不要忘记注册新的自定义收集单元的笔尖。
If you are trying to load a collectionView cell in a collection view which is picked up from a nib then you might be seeing the error" 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle "
When you are loading a collection view from a nib file, you do not have the option to declare a collection view cell on the nib unlike story board.
The correct way is to create a new custom cell , with a new nib and then load it on to the collection view.
Note : don't forget to register the nib of the new custom collection cell.
就我而言,错误是“nib 文件的名称不正确:
建议将它们全部设置为相同,单元格标识符和
nibName
也如此:如果不起作用,请尝试以下操作:
您会发现您的
xib/storyborad
为红色,只需将其删除即可。此外,从项目中删除丢失文件的所有引用。
现在再次拖动该
storyboard/xib
文件 。到此复制捆绑资源。它仍然会显示一个红色文件,但不用担心它会清理项目。
In my case, the error was "Incorrect name for nib file in:
Recommend making all of them the same, the cell identifier and
nibName
as well so make it:If it doesn't work try this:
You will find your
xib/storyborad
with red color.Just remove it. Also, remove all references of the missing files from the project.
Now drag this
storyboard/xib
file again to this Copy Bundle Resources. It will still show you a file with red color but don't worry about it.Command + Shift + K to clean the project and it will work.
就我而言(使用 XCode 12.5 和 Swift 5),问题是我根据 ViewController 的名称选择了 NIBName:
所以我有“TestView.xib”和“TestViewController.swift”。这不匹配,只能通过将我的 ViewController 重命名为“TestView.swift”来解决。
In my case (using XCode 12.5 and Swift 5) the problem was that I choosed the NIBName based on the name of my ViewController:
So I had "TestView.xib" and "TestViewController.swift". This mismatched and could only be resolved by renaming my ViewController to "TestView.swift".