5

We have an app that is already live on app store.

Now we are planning to reduce the app size by programmatically creating all the views & removing respective NIB (XIB) files.

The problem is even when the nib is deleted & not called for, the updated version of the app still points to the old nib, and the issue like this comes up (this image is just an example, the problem is consistent throughout the app) :

enter image description here

Basically, the views get built up by both IB & code.

The only solution we have come up so far is to delete & re-install the app, but asking all the users to do that is undesirable. Moreover, it would also delete their locally stored app data, which is the main issue we are trying to avoid here.


For the above shown example, following code was used to load the ViewController:

Earlier (when the view was built using nib):

    TheNewVC *theNewVC = [[TheNewVC alloc] initWithNibName:@"TheNewVC" bundle:nil];
    [self presentModalViewController:theNewVC animated:YES];

Now (when the view is built programmatically, leading to above issue):

    TheNewVC *theNewVC = [[TheNewVC alloc] initWithNibName:nil bundle:nil];

    UINavigationController *addNavCon = [[UINavigationController alloc] initWithRootViewController:theNewVC];
    [self presentModalViewController:addNavCon animated:YES];

JFYI, even if TheNewVC *theNewVC = [[TheNewVC alloc] initWithNibName:nil bundle:nil]; is replaced by TheNewVC *theNewVC = [[TheNewVC alloc] init];, the problem remains same.


What solution could be there that doesn't involve re-installation of the app. Any way we could delete the nib cache that iOS is referring to, programmatically? OR in worse case, ask users to do that? Any help would be much appreciated.

1
  • do you remove nib file or it still exist in the project?
    – HelmiB
    Commented Mar 3, 2012 at 11:22

1 Answer 1

7

I assume you are running the app from within Xcode. Which does not clear out pre-existing resources from your app bundle. However when you install via the app store, I am sure it does clean your app bundle away and unzips the new version over the top (so old resources are cleared away..)

If you want to be double-sure your .xib won't be loaded, just rename the ViewController class and it will no longer load up the old xib (since it looks for a file called viewcontrollername.xib in the application bundle)

To do this go to the .h for the view controller, right click on the view controllers name, and select Refactor.

8
  • "However when you install via the app store, I am sure it does clean your app bundle away and unzips the new version over the top" - I'm not so sure about that. It's Xcode that builds the app and puts all the resources into it. If it puts in cached data, device would use that data. Commented Mar 3, 2012 at 11:44
  • No, when you 'Run' an app via Xcode it only copies new files into the app bundle directly, so you'll end up with lots of old resources lying around. However a clean build in 'release' mode for the app store will produce a completely fresh .ipa so if the resources have been deleted they will not appear in the app bundle. Subsequently when the user installs from appstore/adhoc the pre-installed app is deleted, and the new ipa bundle decompressed over the top. Commented Mar 3, 2012 at 11:46
  • Either way, even if @BufferStack was worried that resources may still be around, the second part of my answer (renaming the ViewController class) is correct. Commented Mar 3, 2012 at 11:47
  • @TonyMillion: +1 for the Refactor tip. I had a thought about renaming the ViewController classes, but was trying to avoid taking up so much task across all VCs, refactor is lifesaver. Commented Mar 3, 2012 at 11:54
  • 1
    I just ran into the same thing after localizing a XIB, it left the old NIB on my device from the previous version. Installing via the App Store will delete the file since the old NIB isn't part of the bundle when it's encrypted and leaving the old file wouldn't match the signature. Thanks for confirming I'm not nuts! Commented Apr 5, 2012 at 1:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.