2010-10-10

Built my first AIR app for iPhone

Well this past week I got my first ever smartphone, namely an Apple iPhone 4. It wasn't my first choice, I would have preferred a phone running Android, but my carrier had no such phones available...until this week of course (got to love how that works eh?).

Needless to say, after getting familiar with this iPhone, I wanted to see if I could build an app for it and after some research I found out there are several ways to do this:
  1. use XCode
  2. use HTML/JS/CSS
  3. use AS3/Flash
The first method described above is what is used in 98% of cases. You need a Mac and must have downloaded the XCode development environment and you can build an iPhone app (actually any iOS app...so it can run on iPhone/iPad/iPod) in the Objective C language.

Using the second method, you build a web application using traditional HTML/JS/CSS technologies and then compile them into a native iPhone app. There is a tool called Titanium Developer that I found that allows you to do this.

The third and final way to build an iPhone app is to use the Adobe Packager for iPhone. This little piece of technology if you remember caused a big stir back in April 2010 - cause Apple end-up changing its developer agreement and basically did not allow any third party tools, such as this one to compile any code for the iOS. Well I guess people complained and on Sept 9th, 2010, Apple changed their agreement once again, this time allowing such tools to be used. So basically I download it and build a very simple temperature conversion app (Fahrenheit to Celsius).

The Adobe Packager for iPhone allows you to take a SWF file an converted it to a native iPhone application. You can create your SWF file either by using the Flash CS5 authoring tool or by creating an AS3 project using the AIR 2.0.1 SDK in Flash Builder. In my case I built an AS3 project using Flash Builder and once the SWF was generated, I then used the iPhone packager to generate an IPA file. Then this IPA file is imported into iTunes so you can install (sync) the app onto the iPhone itself.

So its pretty cool to create your first iPhone app using AS3 and see it running. But there is a caveat. As I mentioned before, within Flash Builder you have to create an AS3 project to build the app. You can't create a regular Flex project that uses mx:Application or mx:WindowedApplication as its root class. You have to create a simple HelloWorld.as class that extends Sprite. So you can't use any of the regular controls such as mx:Label or mx:Button. Within an AS3 project you can only use the flash.text.TextField class and use that as a label, textbox and as a button where needed. So building an app in this way can be very time consuming to say the least.

Assuming that Apple doesn't change its stance once again, I'm pretty sure Adobe will be improve how we can build AIR apps for the iPhone in the very near future.

Important Note: In order to develop an app for the iPhone you first much purchase an iPhone Developer Certificate and this costs $99/year. Or you can jailbreak your iPhone :)