Search code examples
ioslocalizationxib

Xib not found after localization


I've added a new localization for italian language in my project and after that I localized a xib file to start the translation of the project. The problem is, now when I run my project in the simulator, none of the xibs are found.

(GAIUncaughtExceptionHandler.m:41): Uncaught exception: Could not load NIB in bundle: 'NSBundle ...

I'm instantiating the file owner of this xib using initWithNibName.

I've tried both pure localization of the xib and the base localization, but none of them are working.

I'm initializing the owner like this:

[[SPConfigViewController alloc] initWithNibName:@"SPConfigViewController" bundle:nil];

EDIT:

After I created the localized version of the xib, I decided to just close XCode and open it again, and it worked...


Solution

  • I had the same experience and what a mind trip...

    Process:

    (Assumes a project that has chosen "Use Base Internationalization" in the Project's Info)

    1. Click on a .xib resource in the File Navigator, which loads Interface Builder
    2. Using the File Inspector, click the Localize button
    3. A modal presents asking which language you would like to use ("Base" was unavailable to me, so I picked "English")
    4. Now in the Localized section of the File Inspector a checkmark is next to English and none next to Base, so I checked Base
    5. Then I was given a picker for how I wanted English to be localized: Interface Builder Cocoa Touch XIB or Localizable Strings

    Okay, I was optimistic that this would work, so run...
    ... and crash

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle < /var/mobile/Applications/_____/_____.app> (loaded)' with name '__MY NIB STRING HERE___''

    Clean, Build, Run -> Crash
    Option Key + Clean, Build, Run -> Crash
    Option Key + Clean, Delete App, Build, Run -> Crash
    Option Key + Clean, Reset Simulator, Curse, Build, Run -> Crash

    Quit Xcode, Relaunch Xcode, Build, Run -> Works! WTF.

    I've opened a Bug Report against the issues and would appreciate if you run into this problem that you would duplicate it so the developer tools team knows its a reoccurring issue.