Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base internationalization and multiple storyboard not working right

I'm playing with multiple storyboards and base localization on xCode 4.6. In fact I

I did:

1) edit my project infos localisations: checked "Use Base Internationalization" and added Languages: English, Chinese

2) create a new storyboard called "anotherstoryboard.storyboard"

3) localize my new storyboard (File Inspector / Localize - Localize) using Base internationalization.

4) in my app delegate, I load dynamically my localized storyboard, like this:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"anotherstoryboard" bundle:nil];

case 1: => works

For my new storyboard (step 3) I choose Localization Chinese - Interface Builder Cocoa Touch Storyboard

enter image description here

It works but now I have to maintain localized storyboard, editing them with IB. I don't want such behavior, I just want to use base internationalization and localize .strings files.

case 2: => crashes

For my new storyboard (step 3) I choose Localization Chinese - Localizable Strings

enter image description here

The app crashes saying it can't find my storyboard

'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'anotherstoryboard' in bundle NSBundle </Users/me/Library/Application Support/iPhone Simulator/6.1/Applications/8E036C84-6058-4420-94B4-1726E1F686AD/HelloWorld.app> (loaded)'

What I'm doing wrong ? Why doesn't iOS find the right storyboard in case 2 ?

like image 754
thomas.g Avatar asked Feb 08 '13 13:02

thomas.g


2 Answers

I had just run into the same issue (again) after starting localizing a new storyboard in Xcode 4.6.2. I checked everything was setup up properly as suggested here and elsewhere, and indeed it was.

For me, the issue was resolved by closing the project in Xcode and manually clearing the Xcode “Derived Data” directory (see Xcode preferences) from the Finder. Then I reopened the project, made a clean build, and voilá, the storyboard got compiled properly and worked as expected.

like image 181
Christopher Lenz Avatar answered Nov 10 '22 15:11

Christopher Lenz


You get this error because for iOS 6 (which is required for Base Internationalization) the storyboard file gets compiled into a storyboardc file. Also it copies the strings files belonging to it to the target. Thus on an iOS 6 device there IS no .storyboard file.

To get a storyboard file compiled you need to make sure that is in the Copy Bundle Resources build phase. Then the storyboard compiler (see build rules) kicks in and should compile it. If not, then this is a bug and you should report it.

like image 22
Cocoanetics Avatar answered Nov 10 '22 16:11

Cocoanetics