Flex with Packager for iPhone Tips

Posted on November 15, 2010 | 4 comments

NOTE: Currently Flex SDK even Flex Hero SDK is not optimized for use with Packager for iPhone. This post is meant as an FYI if you are really are trying to use Flex with PFI. Support for iOS and Flex is coming

I will assume you are using the latest Packager for iPhone (PFI) from the labs.adobe.com. Once you have downloaded the bits and are using the pfi command on the command line with your compiled Flex apps you might come across a few issues.

Exception in thread “main” java.lang.Error: Unable to find named traits: mx.collections.errors::ItemPendingError
This is caused when trying to package a debug SWF, which is by default in Flash Builder in the bin-debug. What you want to do is use Flash Builder to export a release build or in the command line mxmlc arguments make sure debug=false is set.

App compiles to ipa but only shows a white background.
This typically is an issue with the fact that they application is trying to load RSL’s which happens in the Flex’s preloader cycle. Thus the app hangs on an error and no preloader is displayed and you get a app with a white background. You will need to merge the framework code into your SWF. Again if you are using Flash Builder go into Properties -> Flex Build Path -> Library Path tab and make sure the merge type on the framework swc’s is set to Merge into code.

The other time this might come up is when you are using a debug version of the SWF in the PFI package step. The app will die somewhere in the preloader and again not get to the application. If you want to play around and see where its dying in the preloader you can use a customer preloader much the com.renaun.preloader.TimedPreloader I used in here.

  • Marc

    Any idea when a new Packager For iPhone will be available that supports AIR 2.5.1 rather than 2.0.1?

    StudioCloud just released an Android app that works with their existing AIR and Flex applications and we are really excited to have an iPhone app. However, the current PFI does not work with 2.5.1 that I am aware of.

    Any news on this or even a prerelease of the new PFI would be great.

    • http://www.renaun.com Renaun Erickson

      I do not have information on release dates, just that Adobe is working on it. And you are correct the PFI 2.0.2 is using AIR 2.0 namespace.

  • http://blog.kukiel.net Paul Kukiel

    I had these errors “Exception in thread “main” java.lang.Error: Unable to find named traits: mx.collections.errors::ItemPendingError” converting Flex 4 apps to iPhone. This was compiling to swf in FlashBuilder then converting to iPhone. To overcome this I simply compiler to swf via command line.

    • http://www.renaun.com Renaun Erickson

      That is because Flash Builder defaults to debug versions of the SWF file while mxmlc on the command line defaults to a release SWF.