Universal apps & iPod touch
We had a really peculiar bug that was discovered just as we were about to deliver a final drop of an app that we developed for a client.
The app is intended to run on iPad and iPhone — its a universal app. The problem was that although the app ran fine on the iPad and iPhone, it did absolutely nothing on the iPod touch. The app would just turn the iPod touch screen black and then do nothing. It didn’t crash. It didn’t generate memory warnings and get booted from springboard by the OS. Nothing. Nada. Zilch.
A quick Google search and StackOverflow search revealed that this isn’t a terribly common problem, but other devs have run into the problem. But no one has written up a definitive fix for it either. (If you are aware of anything that addresses the problem, please let me know — my search-fu may have been off kilter).
UPDATE: My search-fu is coming back online: https://devforums.apple.com/message/343942 addresses the issue with the solution.
As you may know, universal apps are intended to work on all iOS devices (iPad, iPhone and iPod touch). A universal app typically uses much of the same application logic and typically uses different user interfaces to interact with the user. The app may offer more or different functionality based on the iDevice’s features and functions but you have one code base and the iOS determines which part of the code to run based on the type of device that the app is running on.
This doesn’t happen all automagically of course, you need to give springboard a few hints as to which app resources it should use for which devices. There are a few settings in your <appname>-info.plist that do just that. Specifically, you tell the OS which nib file to initially load:
These directives are pretty much self explanatory — when the app is running on an iPad, it should load the nib called “MainWindow.nib”. When its running on an iPhone it should load the nib called “iPhoneMainWindow.nib”. Pretty simple. Right? Right???
But what happens if the device is neither an iPad or an iPhone? What if the device is an iPod touch? You might assume (as we did — and wrongly) that an iPod touch will use the iPhoneMainWindow.nib. After all, for intents and purposes (to a dev anyway) an iPod touch *is* and iPhone. Sure there are some significant differences, but typically you can test for device functionality and ‘Do the right thing” ™.
Through a very complex and sophisticated debugging process (we call it thrashing), my dev partner was examining the <appname>-info.plist file and noticed that there is another ‘Main nib’ entry that can be included in the plist:
Adding a ‘Main nib file base name’ entry (I’ll call it the ‘default’ entry) into the plist and setting it to the iPhoneMainWindow.nib seems to have fixed the problem. The app now runs just fine on all devices including the iPod touch.
Anectdotaly, it appears that the iPod touch is using the default entry, while the iPhone and iPad are using their respective entries in the plist.
The default entry is just that — a default. When I remove the (iPhone) entry from the plist and run the app on an iPhone, springboard uses the default entry and loads the iPhoneMainWindow.nib when the app loads and runs just fine.
Hope this helps other devs out there!!





