Using Apache Ant with FlexBuilder 3 on Mac OSX – Some workarounds
I recently needed to compile a SWC from Flex Builder 3 on my Mac. I hadn’t done that before, as I really hadn’t had the need to share or publish my Flex components with a broader audience. This seemed like it was going to be a pretty straightforward thing to do, but after a while of tinkering about in FlexBuilder 3 with a number of different failures of varying types, it became abundantly clear that simply following the tutorials on LiveDocs, the docs on Labs and the help files in FlexBuilder wasn’t going to cut it. A number of posts on Mike Chambers blog regarding SWC compiling with compc and some messages in the FlexCoder’s discussion list got me closer to my goal, but it still took a lot more tiral and error than I think it should on a commerical product like Flex Builder. The bugs I found in Adobe’s Jira Flex SDK area on the subject were almost laughable, some mentioning compiling SWCs from FlexBuilder 3 on a Mac as an “edge use case”. Really? An edge use case?
FlexBuidler 3 on a Mac is not capable of compiling Flex components to SWC files out of the box. You need to install and configure Apache Ant before you will be able to share your code libraries with other developers.
So, for my own future reference and in the hopes of saving some Mac Flex developers the headache I encountered, here are the steps I needed to take to get Ant to successfully build a SWC that I could use in other Flex projects or give to developers on my team.
Installing Ant For FlexBuilder on OSX
You’ll need to load Ant into your FlexBuilder installation. To do this, open FlexBuilder and go to “Help -> Software Updates -> Find and Install..” Once the dialog appears, choose the “The Eclipse Project Updates” option and click finish. Choose a repository. You’ll need to install The Eclipse JDT package. Confirm the download, accept the agreement and wait for the install to happen. After the install completes you’ll need to restart Flex Builder to see it. After the restart, it should be available to you via “Window -> Other View -> Ant”. Before using it, though, we have a little more tweaking to get it to work.
Configuring Ant For FlexBuilder on OSX.
Add your SDK folder to your system’s $PATH environment variables. This is a simple step in theory, but in practice will cause you some headaches due to the default location of the Flex Builder install. By default, Adobe Flex is installed here: “/Applications/Adobe Flex Builder 3″. The folder has spaces in the name. Typically, when using spaces in folder names, specifying the path to that directory in a shell application requires using encapsulating quotes or the escape character “\” proceeding the space. In this case, using either of those failed for me. In order to workaround this, I needed to create a symlink at “usr/local/flex_sdk, allowing Ant to reach “compc” in a directory that didn’t have spaces in it. If you don’t do this, you’ll end up seeing errors like this.
So to do this, open Terminal and type: “sudo ln -s "/Applications/Adobe Flex Builder 3/sdks/3.2.0/" /usr/local/flex_sdk” – Of course, this assumes your SDK is located in “/Applications/Adobe Flex Builder 3/sdks/3.2.0/”, which for me, on a default FlexBuilder3 install, it was.
Once that is done, you may edit your “.profile” file to add the symlinked directory (pointing to your Flex SDK) to your $PATH environment variable. You have to do this, because without it, when Ant fires off the Compc Task, your Mac won’t know where the compc application is. You can use any text editor you like to edit the file, but since the file has a “.” prefix in the name, the file is invisible by default to the finder. Pico, Vi, etc in the Terminal have no problem with hidden files, and BBEdit is also capable of opening hidden files via the “File -> Open Hidden…” command. Your edited .profile file should look something like this after you are done:
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/flex_sdk/bin:/usr/local/flex_sdk/lib:$PATH
Once this edit is complete, logout of the Finder, log back in and check that the edit stuck by using this command in your Terminal:
echo $PATH
After that fun is over, you should be able to fire up Flex Builder… Once you have some AS you want to turn into a Ant Project, you’ll need to write a build.xml file and a build.properties file. Pretty much all the other tutorials out there on using Ant with Flex work after this point, so I won’t bore you with those details. After everything is working, I have to say Ant is pretty cool and I’m already thinking of some cool things to use it for to automate my workflow and speed up testing and deployment.
That said, I surely hope that FlexBuilder 4 fixes some of these dicier development issues that seem to plague FlexBuilder 3. Honestly, avoiding stuff like this was one of the main reasons I have paid for a FlexBuilder license, rather than simply downloading the free SDK and using the free Eclipse IDE, so if 4 doesn’t fix a lot of this stuff, I’ll likely do that. Writing MXML is easy enough, and with Catalyst just around the bend, it might supplant one of the bigger benefits of the FlexBuilder design view, so this seems even more plausible for many now than it did around the release of FlexBuilder 3.
In closing, I hope this article helps you, and if does, please comment below. If things aren’t working for you after following the tips in this post, comment and I’ll try to help you out!
Posted on April 27, 2009





Anselm Bradford Apr 27
Chad, this might interest your readers… instructions for using the free Flex SDK on OSX: http://blog.anselmbradford.com/2009/01/06/curious-about-adobe-open-source-get-started-with-the-flex-sdk-on-mac-os-x/
match May 18
Hey thanks a lot for the link anselm. that will be very helpful
Jukklue Jun 24
very good tutorial
by the way, i`m quit new in programing and new user for Mac so i got some problem to follow, that is
In Terminal and type: ‚Äúsudo ln -s “/Applications/Adobe Flex Builder 3/sdks/3.2.0/” /usr/local/flex_sdk‚Äù
the result is “No such file or directory”
should i make a blank directory named “flex_sdk” or change /usr/local/flex_sdk to any nonspace named folder
thanks in advance,
Jukklue
Chad Jun 24
Jukklue, your problem is probably that you have a different Flex SDK than I did when I wrote this…
What SDKs do you have located in here – “/Applications/Adobe Flex Builder 3/sdks/”
You may have 3.3 or something else… change the “3.2.0″ part of my instructions to whatever SDK you have.
Steven Jun 24
Great article!!!
Also the post encapsulates the entire command in quotes. Instead use:
sudo ln -s “/Applications/Adobe Flex Builder 3/sdks/3.3.0″ “/usr/local/flex_sdk”
Jukklue Jun 28
my Flex SDK is 3.2.0, i think this”/usr/local/flex_sdk” is not exited in my mac. i`ll asked unix user to help about it
Horror Jul 16
Thanks for the link dude! Helps a lot
mikew909 Sep 1
Great Post
Im curious tho – is creating a symlink the same as copying the sdk to a location without whitespace?
cheerz!
Eonil Sep 5
Hi. I’ve been reported a bug to Adobe JIRA about Ant failure on spaced path.
If you interested to solve this problem. please vote for it to make Adobe consider it.
ANT Custom Builder always just fails if space character exists in FB installation path on Mac OS X. (It’s working well with space-less path.)
http://bugs.adobe.com/jira/browse/FB-22548