The time has come to upgrade to iOS 4.3 and Xcode 4. Grrr. The main problem I was having I could not find anywhere on google or in the dev forums, so I thought I should post my problem and fix here (after the jump) to hopefully help the next guy.
In general I suppose I resist change. But for iOS app development I also sortof fear change because it means having to learn something new, and historically this is a time-suck of anywhere from a few nights to a week or so. Of course Apple has to keep releasing new features, improving old features, adding capabilities, etc. This is required to maintain their number one spot in the marketplace. So, I get why it has to happen. But being a one man development shop, any time some new os is released it means I’m the only one to update everything to support the latest software. What I fear the most is any new product release from apple. Well, actually I’m torn on this because as an apple consumer /slash/ fanboy, I want new stuff. But as a developer who has to support the new stuff, I fear it. For example, if Apple were to add a retina display to the iPad and double the pixel resolution… it would throw me into a tailspin. Supporting such a high resolution iPad would mean redoing a lot of my graphics. I could skip it, but the key to success in the app store is being among the first to support the new features that Apple is pushing. So I’d have no choice but to dig in and do it as fast as possible.
Anyway, here I am a couple of days into trying to use Xcode 4 and iOS 4.3. I’m not sure which of those two updates is causing the problems, but I’ve been battling it…
Actually I’ll skip all the details of installing, having some corrupted settings, having permissions issues, hard drive corruption, deciding to install a new root drive, and then reinstalling clean developer software. I’ll skip all of that because that was likely a fluke.
No.. the problem I’m having is this:
2011-03-23 03:46:20.516 UICatalog[9809:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/username/Library/ Application Support/iPhone Simulator/4.3/Applications/67E625C1- 7BE6-47A6-B777-EC9A03FF866F/UICatalog.app> (loaded)' with name 'MainWindow''
This is happening mostly with older sample code that I have lying around. But also with all my current apps, which were all originally developed back in the iOS 2.x – 3.x days. I’m still working through the issue, but I have been able to make the error go away with a couple of fixes.
First keep in mind that you can look in the path shown above to find the app package in the simulator’s Applications folder. Show Package Contents and look to see if the missing file is in there. That’s a good place to start.
Next is to make sure that in the info.plist for the app that you are not listing the .xib extension for the ‘Main nib base name’. This means do this:
Main nib base name MainWindow
instead of this:
Main nib base name MainWindow.xib
The .xib gets compiled and turned into a .nib when placed in the bundle for the app. So when I was listing the extension it might have been looking for MainWindow.xib.nib, and of course that file isn’t going to be there. Also it’s not asking for the full name, only the base name. Now that I think about it, I’m not sure if the .xib was there in my Xcode 3 project or not. It’s possible that I added it when I tried removing and re-entering the plist entry. Still I figure it’s worth mentioning.
The last thing, and probably the more likely problem has something to do with the version of Interface Builder the .xib was saved with. There was something mentioned in the release notes about this, but it was written in code – not in regular guy english. Since I’m still figuring all this out I experimented and found a solution inside of Xcode 4: One by one select each .xib file and in the tab on the right under “Interface Builder Document” and make sure your deployment is set to “Project SDK”.
Then recompile and hopefully you’ll be golden.
UPDATE: Not So Fast…
Even after doing all this I still had some crashing issues. I looked in the app bundle, which as I said above can be found in the folder specified in the error log, and there were all the .xib files but no .nib files. And all the .xib files were in an english subfolder. Back in my project folder (on the hard drive not in xcode) I moved them out. This caused xcode to squawk! Probably should have done it with the project closed. Still I got past all the warnings and then re-added all of these files to the project and deleted all the old ones.
I’m not sure which of the things actually fixed the issue. It could have been moving the files out of a subfolder in Resources. OR it could have been the fact that the .xib files were removed and re-added to the project in xcode. Either way it’s working now. At least it gives you a few things to try if you run in to the issue.
UPDATE #2: Remove and Re-add is the trick
It happened on another project. I’m glad I wrote this blog post cause it helped me figure it out in a few minutes instead of a few hours. This time it turned out to be removing and re-adding the xibs in the project. They were already in the root folder of the project (in finder), I moved them to the root of the project (in xcode), they were also already set as Project SDK version, and I upgraded their Development setting to IB3.2. But to get it to work I had to deleted them from the project (in xcode), selected to only remove references, then dragged them back in from the finder, recompiled and all is golden now.