Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6.3: Could not load NIB in bundle

Tags:

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

like image 610
Cameron Spickert Avatar asked Apr 09 '15 20:04

Cameron Spickert


People also ask

Could not load NIB in bundle bundle?

It happens when you rename the nib file. If you have already, create new nib(meaning copy current nib file contents to new nib), delete old nib file and it will solve your problem.

How do I load a nib in Swift?

mainBundle(). loadNibNamed("SomeObject", owner: self, options: nil) self. addSubview(self. view); // adding the top level view to the view hierarchy } required init(coder aDecoder: NSCoder) { super.


2 Answers

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

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

  • You have a device-specific input file *~(iphone|ipad).xib with size classes enabled.
  • Your deployment target is anything older than 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.

like image 110
Cameron Spickert Avatar answered Sep 27 '22 20:09

Cameron Spickert


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

like image 41
Praveen Matanam Avatar answered Sep 27 '22 21:09

Praveen Matanam