Debug both Flex and AIR apps from the same FlexBuilder project

For some reason FlexBuilder forces you to choose between creating Flex projects and AIR projects, and it doesn’t let you change a projects nature after it’s been created. This means that if you create a Flex project you will not be able to compile, debug or profile any AIR applications that you happen to build from the same code base. This has annoyed me to no end, but I have finally found the solution.

FlexBuilder stores it’s project preferences in a file called .project in the project’s root directory. By looking at the difference between a project created as a Flex project and one created as an AIR project I found that the only real difference is in the <natures> tag. This is how it looks for a Flex project:

<natures> <nature>com.adobe.flexbuilder.project.flexnature</nature> <nature>com.adobe.flexbuilder.project.actionscriptnature</nature> </natures>

And this is how it looks for an AIR project:

<natures> <nature>com.adobe.flexbuilder.project.flexnature</nature> <nature>com.adobe.flexbuilder.project.actionscriptnature</nature> <nature>com.adobe.flexbuilder.apollo.apollonature</nature> </natures>

Simply add that com.adobe.flexbuilder.apollo.apollonature to a Flex project’s .project file and restart FlexBuilder and create a new run, debug or profile configuration (Run → Run/Debug/Profile → Other…) in the AIR Application section. To be able to select a main MXML file it has to be set as a runnable application file. This is done in the project properties (right click on the project in the Flex Navigator and select properties) in the Flex Applications screen.

How to find the run/debug/profile configurations dialog

There’s just one little snag: as long as your project has the “apollo” nature you can’t create new Flex configurations, but that can be fixed by simply undoing the changes to the .project file. The configurations you have created will remain and will work (although they don’t always appear in the Run menu, you may have to go into the run configurations dialog to find them, I haven’t really figured out why).

3 Responses to “Debug both Flex and AIR apps from the same FlexBuilder project”

  1. Improve Compile Times in Flex Builder - Flex and its Environs Says:

    [...] If you need to develop both Web and Air side-by-side, you can put your application code in a folder which you then include via source-path in two projects, one air and one flex. Either that or use this trick. [...]

  2. Robert Says:

    What you’re describing is more of an eclipse thing. I’ve changed back and forth from Java to FDT projects using the exact same methodology.

  3. ryan Says:

    thats also the reason why you should never commit any of your .project files to svn… its a real pain and screws with your ide when you update from somebody elses codebase only to find your natures have been overwritten…

    i once worked a project where some of us used fdt and others flex builder…

    oh and did you also know that you can store your run configurations as a local shared file under the “Common” tab

Leave a Reply