Compiling big Flash/AIR projects with lot of SWFs for iOS

This is a nice little trick that can solve you lot of issues.

When you are building a game for Android or Blackberry Tablet OS in Adobe AIR, you are allowed to load the SWF files on the fly – that’s because the code is interpreted from ActionScript bytecode. With AIR for iOS, there is no such option, all code must compiled into single IPA file (from ActionScript bytecode to native bytecode), which you can make out of one SWF only.

Now – what if I have a project with 30 or 40 levels, where every single level is a single SWF? How do I compile this to iOS?

Well, for testing purposes, you can just use ipa-test-interpreter switch in compiler settings and it will run the same way like on the Android or the BlackBerry Tablet OS. But this method is not allowed by Apple, so you won’t be able to submit the app to the App Store.

Solution = SWC

The proper solution is to compile all levels to SWC libraries, which you link to final SWF file. That way you can make single SWF file with all the necessary levels compiled in it.

In Flash Builder, you have to transform your project from ActionScript project (output SWF) to Flex Library Project (output SWC).
Flex Library Projects creates SWC

In Flash Pro CS5.5, there is this option in Publish settings

Publish settings SWC library instead of SWF

And also last few notes:
- you can use AS3-only projects for AIR, you can’t get AS2 game to iOS with AIR for iOS
- you can load SWF files even on iOS, but the code inside them won’t be interpreted – so it’s useful for graphical assets like animations or vector graphics – you can have a library full of symbols and just pick a symbol that you want

Show Comments

Hide Comments

Comments are closed.