2
votes

I'm starting to get into Mac OS X development and I have a problem the solution to which I haven't been able to figure out for the last three hours (I've googled a long time).

Test application:
I have an application that has a MainMenu.xib, which displays a window - so far so good. I've created another XIB and NSViewController subclass that contains a view which I want to display within the main window. I use the following code to load the view and insert it into the main window:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    self.compartmentViewController = [[SelectCompartmentViewController alloc] initWithNibName:@"SelectCompartmentViewController" bundle:nil];
    [self.compartmentViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
    [self.compartmentViewController.view setFrame:[self.contentArea bounds]];              
}

compartmentViewController is a property and self.contentArea is a custom view on the main window - like a placeholder.

This works fine so far.

Problem
Then I decided to check out the localization feature. I've localized a couple of strings and both XIBs. At first I was a bit confused by not seeing any localized values. That was until I found out I had to clean the project - since then I've been getting the following error when running:

2013-03-19 22:48:59.763 Vocab Box[10160:303] unable to find nib named: SelectCompartmentViewController in bundle path: (null)
2013-03-19 22:48:59.764 Vocab Box[10160:303] -[NSViewController loadView] could not load the "SelectCompartmentViewController" nib.

Suggested solutions I've tried to no avail

  1. Cleaning the project doesn't help
  2. Checking the build configuration - yes, the bundle resources seem to be ok
  3. Yes, if I remove the localization for my subview and re-add the original XIB, things are fine again (though of course the view is not localized)

Help

3

3 Answers

7
votes

I don't have an answer as to why this happens. But I had the same problem, and I fixed it by closing xCode and opening it up again, believe me.

1
votes

Try the following :

  • select your project
  • select "build phases"
  • add the new xib in the "copy bundle resources"

enter image description here

0
votes

I just had this same issue and was able to solve it by doing the following:

1) Select the XIB in the project navigator

2) In the File Inspector, uncheck any items under Localization (it will prompt you - make sure 'delete files from disk' is unchecked, and press Remove)

3) Manually add the XIB back into the project