Supporting old iOS hardware

The sound project I am working on has as one of it’s goals the ability run on anything iOS, like the old iPhone 2g. There are, so far, no reasons not to be able to do so, we don’t push 100K polygons or anything like that.

But this is actually quiet challenging.

Those are the small hurdles:

a) there is no build system provide functionality. You should always build with the latest and greatest XCode SDK. So you use iOS 4.2.1. You set your target to 3.1.3. And then you build happily, using functions and methods that did not exist in 3.1.3. You do not get a warning, you do not get an error. All you get is a crash when  you try to run this on that platform.

b) XCode does not, in one installation, allow you to run your image on all versions of the software. E.g., XCode with iOS SDK 4.2.1 does not include a simulator for iPhone 3.1, 3.2… it starts with 4.0.

The lesson learned is that if you want to ship something for iOS, you should have all the hardware that you want to support. Otherwise you are guessing. Or you need to preempt all API calls with selector tests, which probably will bloat your code to 2x it’s regular size.

There are in my project just 2 areas i had to work on so far that were dramatically different in iOS 3.1.3 vs. 4x.

Cut/Copy/Paste

In the times before 3.2 you had no custom Pasteboard commands. So on 3.1.3 the program crashed as soon as you tried to work with those objects, as they don’t exist in the runtime. So I started coding 2 alternative parts, one with the custom menus, which already existed, one using the default menus. The funny thing is, that currently I disabled the post 3.2 code path, as the default menu system is actually nicer to use and more easy to understand than the custom one I came up with before. So refocussing on how to do the same thing using the default actions made the program actually better, I think.

Audio file creation

The other thing I was bitten is the creation of MP4 files. Using ExtAudioCreateFile I was able to use the hardware AAC encoder to take the LinearPCM sounds I create and stream them into ExtAudioFileWrite, and let the hardware encoder do the rest.

No such luck on iOS 3.13. There is no hardware encoder, and, also no software alternative. So i needed to change the code to create a .CAF file instead of an MP4 and use LinearPCM as the encoding, meaning no encoding. Makes the files bigger, but the feature still works.

All in all fixing those 2 things took me 2 good days of work, mostly research and trying to figure out what is possible in the first place, especially in the CoreAudio case. But I think if it is just 2 days, it’s worth doing to support a few million more potential customers.

Advertisement

1 comment so far

  1. Excellent Apps on

    mmm… Interesting…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.