3

On the face of it, this seems a very simple problem but for some reason I can't quite get it to work.

I have a magazine-style app that downloads the data for each issue in the form of a zipped bundle.

Once downloaded, and unpacked, the app successfully accesses the various files contained within the bundle as expected. These include JSON, PNG, JPG, video and so on.

However, I also included a XIB file that contains the physical layout of the content in a series of UIViews and it is this file that I cannot use.

The file is present but when I try and load it using:

UIViewController *controller = [[UIViewController alloc] initWithNibName: @"ViewController" bundle: assetBundle];

I get the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/C6718DB8-0C0F-4D38-84E6-55C145279957/Documents/asset-4.bundle> (not yet loaded)' with name 'ViewController''

Now, is this an iOS imposed limitation on not accessing XIBs from downloaded bundles, or some mistake I'm making in calling up the XIB for use?

I cannot find any explicit prohibition on using fetched bundles in this way however.

reddersky
  • 963
  • 1
  • 11
  • 28

1 Answers1

10

I am unsure if you can 'legally' get away with this. But the problem is likely you are suppling a 'xib' instead of the compiled version the 'nib'.

You can do this manually from the command line by using the provided ibtool program.

ibtool --errors --warnings --output-format human-readable-text --compile ${OUTPUT_NAME} ${INPUT_NAME}

You'd then place the compiled .nib file into the bundle and load as you've been trying.

Joshua Weinberg
  • 28,598
  • 2
  • 97
  • 90
  • 1
    I guess it's legal because XIB is not executable code, but just interface layout. – AlexeyVMP Jan 08 '12 at 19:20
  • Here's hoping it is! I've submitted a request to Apple anyway to find out - will post detail on their response when I have it. – reddersky Jan 08 '12 at 19:32
  • It is likely fine, as you aren't loading any executable code. But there is always the chance. – Joshua Weinberg Jan 08 '12 at 19:41
  • I was compiling at the derived data location instead of the folder where the bundle was created. Thanks. –  Feb 09 '12 at 00:58
  • Any clues what that means? Interface Builder Cocoa Touch Tool[40004:13603] CFPreferences: user home directory at file://localhost/Users//Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile. –  Feb 09 '12 at 00:59