Xcode 6.3:无法在包中加载 NIB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29547861/
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 06:56:44  来源:igfitidea点击:

Xcode 6.3: Could not load NIB in bundle

iosxcodeinterface-builder

提问by Cameron Spickert

When compiled using Xcode 6.3 (iOS 8.3 SDK), some nib filenames end up with an extra ~ipador ~iphonein certain circumstances. For example, ViewController~ipad.xibbecomes ViewController~ipad~ipad.nib. This is causing a crash because the app doesn't expect the compiled nib files to have the double suffix.

使用 Xcode 6.3 (iOS 8.3 SDK) 编译时,某些 nib 文件名以额外~ipad~iphone在某些情况下结束。例如, ViewController~ipad.xib变成ViewController~ipad~ipad.nib。这会导致崩溃,因为应用程序不希望编译的 nib 文件具有双后缀。

回答by Cameron Spickert

To fix this, uncheck “Use Size Classes” in any affected documents in Interface Builder.

要解决此问题,请取消选中 Interface Builder 中任何受影响文档中的“Use Size Classes”。

This appears to be a bug in the version of ibtoolincluded with Xcode 6.3 (and the iOS 8.3 SDK). It's happening in the following circumstances:

这似乎是ibtoolXcode 6.3(和 iOS 8.3 SDK)附带的版本中的一个错误。它发生在以下情况下:

  • You have a device-specific input file *~(iphone|ipad).xibwith size classes enabled.
  • Your deployment target is anything older than iOS 8.0.
  • 您有一个*~(iphone|ipad).xib启用了大小类的特定于设备的输入文件。
  • 您的部署目标早于 iOS 8.0。

I was able to reproduce the problem on the command line:

我能够在命令行上重现该问题:

xcrun --sdk iphonesimulator8.3 ibtool --minimum-deployment-target 7.0 --compile ViewController~ipad.nib ViewController~ipad.xib

If you're seeing the same behavior, please duplicate this radar.This appears to be fixed in the latest Xcode 6.4 beta.

如果您看到相同的行为,请复制此雷达这似乎在最新的 Xcode 6.4 beta 中得到了修复。

回答by Praveen Matanam

change ~ to _ in the xib name and specify explicitly the suffix while loading the bundle programmatically.

将 xib 名称中的 ~ 更改为 _ 并在以编程方式加载包时明确指定后缀。

回答by Tomas Sykora

I had some files named with ~ and I renamed them, but it did not help, the thing is that I have no XIB files, I even tried to change my Storyboards to Size Classes.

我有一些以 ~ 命名的文件,我重命名了它们,但它没有帮助,问题是我没有 XIB 文件,我什至尝试将我的故事板更改为大小类。

Nothing is helping, I have build target set to iOS 7 and I really need to support iOS 7.

没有任何帮助,我已将构建目标设置为 iOS 7,我真的需要支持 iOS 7。

I do not know what handle NIB loading in code means...

我不知道代码中的处理 NIB 加载是什么意思...

One more time, the problem is that my App in AppStore started to crash on iOS 8.3, and if try to build the App in XCode 6.3 using my iPad Air running iOS 8.3 it crashes right away with this message:

还有一次,问题是我在 AppStore 中的应用程序开始在 iOS 8.3 上崩溃,如果尝试使用运行 iOS 8.3 的 iPad Air 在 XCode 6.3 中构建应用程序,它会立即崩溃并显示以下消息:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ....

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ....

Thanks for help.

感谢帮助。

回答by joobik.com

This appears to be a bug of Xcode 6.3 when compiling XIB files. In order to workaround the exceptions there are 4 Options:

这似乎是 Xcode 6.3 编译 XIB 文件时的一个错误。为了解决异常,有 4 个选项:

  1. Target your project to iOS 8
  2. Use storyboards instead of XIB files
  3. Disable Size Classes
  4. Handle NIB loading in code
  1. 将您的项目定位到 iOS 8
  2. 使用故事板代替 XIB 文件
  3. 禁用大小类
  4. 在代码中处理 NIB 加载

I detailed each of these options in my blog post: http://www.joobik.com/2015/04/fixing-xcode-63-ios-sdk-error-could-not.html

我在我的博客文章中详细介绍了这些选项:http: //www.joobik.com/2015/04/fixing-xcode-63-ios-sdk-error-could-not.html