Adobe recently resurrected their Packager for iPhone, which takes a Flash or Air program and turns it into an iPhone app. I’ve been trying it out by converting an old game of mine. I’ve made progress, but I’ve had some struggles.
Conversion of a pure AS3 project compiled with the Flex compiler worked quite simply. After I figured out the deployment process (which I talk about below), the game just worked. It wasn’t sized to the screen, of course — 320×480 is a weird-ass resolution — but it worked.
Of course, if I want to use hardware features like the accelerometer or adjusting the screen orientation in a clever way, I can’t use a simple AS3 project. I need to turn my game into an Air app. That’s also a simple process; I can switch it over in a few minutes and have it running on my PC.
But not on my iPhone. On my iPhone, it breaks hard. There’s some sort of exception happening at startup, I think, and to debug it I’ve tried using fdb, the Flash debugger. This is my first time using a command-line debugger; in the past I’ve always used the convenient IDE debuggers, but FlashDevelop won’t receive the remote connection from the phone. Unfortunately, despite getting fdb working, it isn’t seeing the error.
So I’m reduced to the most primitive form of caveman debugging: commenting out my entire application and slowly uncommenting functions until I find the error. So far, I’ve found one problem:
The iPhone packager doesn’t seem to like dynamic classes.
That isn’t the only problem, though, and the process for this thing is a nightmare. Here’s the steps I take to debug and test:
- Change the code.
- Test on the PC.
- Fix any issues and retest on the PC.
- Run the iPhone packager, which takes about a minute.
- Delete the previous version of the test app from my phone.
- Load the new app file into iTunes and tell it to yes, replace the old app, and no, don’t apply changes to the phone
- Check the app as active and apply changes, then wait another minute for the phone to sync.
- Start FDB and tell it to listen for the iPhone.
- Start the app on the phone.
At this point, the app hangs and FDB tells me nothing, so I start the process over.
This is really frustrating.
On the bright side, the packager works like a charm for non-AIR apps, and I don’t need an Apple machine for it. The performance on the iPhone seems fine even with my old, embarrassing, unoptimized code, although I haven’t done any substantive tests. It’s actually really exciting to see my game running on the iPhone; the physicality of the device makes it seem much more immediate.
If you can lay hands on a Mac of some sort, you might be able to get more debugging info out of the iPhone simulator. On the other hand, it sounds more like a problem with the Flash packager than your code itself, so a stack trace at that level might be useless.