Update: I have updated these instructions to work with the final release of the Flex SDK. The new location is:

http://www.joshbuhler.com/xcodeflex/

I’m going to be honest. Until recently, I just couldn’t see what all the big fuss over Flex was. Sure, it seemed neat, but I just couldn’t see the point in using it when a lot of the stuff it offered I figured I could just build myself. The price tag was also a big turnoff.

However, with the news that the Flex SDK will be available free of charge, that was a good push in the Flex direction for me. The other thing that’s changed my mind on Flex is having actually used it.

While at MAX, I attended one of the “Hands-On” sessions where we built a simple Flex application, that took around 20 minutes of actual development time. That same app would’ve taken about two hours for me to do from scratch in Flash. Also, over this last weekend, I spent some quality time with the Flex Builder Beta on my Windows machine. (My Mac was busy rendering some videos for something.)

I started building the interface for a project I’ve been working on for a while, and in about an hour’s time, I had the login, password recovery, “My Account”, and Dashboard areas completed. Again, something that would’ve taken much longer in Flash.

I’m sold.

However, as people know, I’m a Mac guy at heart, and as nice as Flex Builder is, I still really like using my Mac. Once it’s available for the Mac, most likely I’ll be using it. However, until then, I’d still like to work on my Mac. I’ve set up an Xcode project template that can be used to build a Flex application, using the latest mxmlc compiler from the Flex 2 beta.

Building Flex 2 Apps in Xcode

To use Xcode, you’ll first need to do some setup:

  1. Download and install at least the Flex Frameworks from labs.macromedia.com. You’ll need to do this on a Windows machine. Once it’s done installing, from the install directory, copy the “lib” and “frameworks” directories to your Mac.
  2. Copy these files to “/Developer/SDKs/Flex”. You may need to create this folder.
  3. Download this project template, and copy it to “/Library/Application Support/Apple/Developer Tools/Project Templates/Flash”. You may also need to create this folder yourself.
  4. If Xcode is open, restart it, and create a new project. You should now have a “Flash” heading in the project type list, with “FlexApplication” under it. This should create a new Flex project, with a bare-bones MXML file. If you click the build button, Xcode will start up mxmlc to compile the included MXML file. Just remember to base your application off of this file for the compiling to work.

However, if you’d still like to just use the command-line to run the compiler, you can still do so, however, it appears that some of the syntax has changed. You now need to specify the config file to use, so the command to compile would now be like so:

java -jar "/Developer/SDKs/Flex/lib/mxmlc.jar" -load-config "/Developer/SDKs/Flex/frameworks/flex-config.xml" -file-specs myFileName.mxml

Of course, you’ll need to make sure that the paths to the config file and mxmlc.jar match your system. (Thanks Jules)

Hopefully we Mac users will get some Flex/AS 3.0 lovin’ from the Adobe Labs soon, (Lightroom is nice, but Flash/Flex would be nicer,) but until then, I guess we’ll just have to make do with these methods. Have fun!