Note: I added a haXe Xcode project template to the haxeXcode.zip pacakge (5/5/2006)
It turns out that, with a bit of effort, you can turn Xcode into a solid haXe IDE.
First, Xcode can provide excellent code highlighting and auto completion for haXe. To enable them, you have to install haXe language support files. You don't need to go through the trouble of creating such files yourself -- go ahead and download the ones I created: haxeXcode.zip.
To install haXe language support, unzip the package, put haxe.pbfilespec and haxe.pblangspec in /Library/Application Support/Apple/Developer Tools/Specifications/ and restart Xcode (note: haXe code highlighting is only enabled for files ending with .hx). If you only want the plugin to be installed for your user account, make the root path ~/Library.
(To create the language definition files, I modified the script for generating Actionscript language tokens I found on mabwebdesign.com to parse haXe source and output haXe language tokens. I then modified the Actionscript language definition files provided with the original script to support the haXe language. As you can see, most of the work has already been done for me :) )
Second, the Xcode + MTASC trick I wrote about in a previous posting also works with haXe. You're probably too lazy to go back and read it, so I'll explain: if you call the haXe compiler from an Xcode shell script target, Xcode will correctly interpret haXe's error messages and point you at the problematic line in your code (tip: you can press Apple + '=' to jump to the error's location).
Here's the best way of setting up Xcode's build system for a haXe project:
- Create a new shell script target called 'build'.
- Edit the shell script to invoke the haXe compiler (example: "haxe compile.hxml").
- Create another shell script target called 'run'.
- Add the target 'build' to the new target's list of dependencies.
- Edit the 'run' script to open the generated swf (which you should embed in an html page) in Safari
(example: "open -a /Applications/Safari.app build/index.html")
When you set things up in this manner, if 'run' is your active target and haXe runs into a compilation error during 'build', Xcode will abort before reaching 'run' and Safari won't be opened, which would otherwise be a horribly annoying behavior. By my experience, this setup greatly speeds up development and testing.
Note: this is a new edit (5/5/2006). If you don't feel like going through all these steps yourself, you can install the haXe Xcode project template I created, which is included in haxeXcode.zip. Simply put the folder called "haXe Application" in /Library/Application Support/Apple/Developer Tools/Project Templates/Application and restart Xcode. Now, when you create a new project, you'll see "haXe Application" as an option under "Application." Just make sure to edit the "run" target's script to point at your location of the haXe executable. (The reason I chose to invoke Safari from a shell script is that the 'open' doesn't launch a new Safari process in case Safari is already running.)
Final tip: I set up CTRL-space as auto-complete key-combo. I use it all the time and it greatly speeds up coding.
Hope this helps! Let me know if you have any comments or suggestions.