Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Could Not load nib in bundle

The Error says 2015-09-27 12:37:06.672 Log Your Holiday Final Mockup[6702:331614] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/aryankashyap/Library/Developer/CoreSimulator/Devices/0C1D2C47-65B3-49E0-B1E4-3AB3F0B415A4/data/Containers/Bundle/Application/D083CB2F-2C5B-4A5D-B4BE-216134050575/Log Your Holiday Final Mockup.app> (loaded)' with name 'raj.xib'' *** First throw call stack: ( 0 CoreFoundation 0x000000010168ef65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000101108deb objc_exception_throw + 48 2 CoreFoundation 0x000000010168ee9d +[NSException raise:format:] + 205 3 UIKit 0x0000000101ffedb1 -[UINib instantiateWithOwner:options:] + 499 4 UIKit 0x0000000101dea84d -[UIViewController loadViewFromNibNamed:bundle:] + 381 5 UIKit 0x0000000101deb179 -[UIViewController loadView] + 178 6 UIKit 0x0000000101deb47c -[UIViewController loadViewIfRequired] + 139 7 UIKit 0x0000000101debc7d -[UIViewController view] + 27 8 Log Your Holiday Final Mockup 0x0000000100bc16fe _TFC29Log_Your_Holiday_Final_Mockup34DomesticDestinationsViewController11viewDidLoadfS0_FT_T + 590 9 Log Your Holiday Final Mockup 0x0000000100bc2232 TToFC29Log_Your_Holiday_Final_Mockup34DomesticDestinationsViewController11viewDidLoadfS0_FT_T + 34 10 UIKit 0x0000000101deb931 -[UIViewController loadViewIfRequired] + 1344 11 UIKit 0x0000000101e2ec26 -[UINavigationController _layoutViewController:] + 54 12 UIKit 0x0000000101e2f4dd -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 433 13 UIKit 0x0000000101e2f633 -[UINavigationController _startTransition:fromViewController:toViewController:] + 116 14 UIKit 0x0000000101e30879 -[UINavigationController _startDeferredTransitionIfNeeded:] + 890 15 UIKit 0x0000000101e3167d -[UINavigationController __viewWillLayoutSubviews] + 57 16 UIKit 0x0000000101fc963d -[UILayoutContainerView layoutSubviews] + 248 17 UIKit 0x0000000101d1111c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710 18 QuartzCore 0x00000001067d836a -[CALayer layoutSublayers] + 146 19 QuartzCore 0x00000001067ccbd0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 20 QuartzCore 0x00000001067cca4e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 21 QuartzCore 0x00000001067c11d5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 22 QuartzCore 0x00000001067ee9f0 _ZN2CA11Transaction6commitEv + 508 23 UIKit 0x0000000101c5b1b6 _UIApplicationHandleEventQueue + 7183 24 CoreFoundation 0x00000001015bb0a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 25 CoreFoundation 0x00000001015b0fcc __CFRunLoopDoSources0 + 556 26 CoreFoundation 0x00000001015b0483 __CFRunLoopRun + 867 27 CoreFoundation 0x00000001015afe98 CFRunLoopRunSpecific + 488 28 GraphicsServices 0x000000010628dad2 GSEventRunModal + 161 29 UIKit 0x0000000101c60676 UIApplicationMain + 171 30 Log Your Holiday Final Mockup 0x0000000100bc652d main + 109 31 libdyld.dylib 0x00000001044fa92d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

the code is:

import UIKit

class DomesticDestinationsViewController: UIViewController {

    @IBOutlet var destScrollView: UIScrollView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        let raj : Rajasthan = Rajasthan(nibName :  "raj.xib" , bundle : nil)
        let him : Himachal_Pradesh = Himachal_Pradesh(nibName : "HimachalPradesh.xib" , bundle : nil)

        self.addChildViewController(raj)
        self.destScrollView.addSubview(raj.view)
        self.didMoveToParentViewController(self)

        self.addChildViewController(him)
        self.destScrollView.addSubview(him.view)
        self.didMoveToParentViewController(self)

        var himFrame  : CGRect = him.view.frame
        himFrame.origin.x = self.view.frame.width
        him.view.frame = himFrame

        self.destScrollView.contentSize = CGSizeMake(self.view.frame.width * 2, self.view.frame.size.height)


    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

1 Answer

Hi there,

I'm no expert on issues with, or use of, nibs. However, do you need the .xib extender in your code? I think it is looking for a .xib file and you might just have to specify its name?

Also, there used to be some autocorrection of upper/lower case letters when using the simulator. That's been changed now so make sure your file names are correctly cased.

Sorry I can't be of much more help than just a couple of suggestions.

Steve.