Using HaXe and NME to target Android and iOS

You created your first Hello World app, but you're left wanting more. You've heard all these buzz words about HaXe being cross platform and you want to get your app onto Android or iOS today. This is where NME comes into play, which provides an easy mechanism to build an app and test it on a mobile device or simulator.

Hopefully you already installed NME and you are ready for the next step.

It's Time to Play

Let's grab a flashy example to excite our inner child. This project uses the Actuate animation library to animate colored circles. So make sure you have Actuate installed by running the following command:

haxelib install actuate

Great, we have every dependency installed and we are now ready to start building. To build with Android, you must have a physical device connected. However, if you are building for iOS you just need to have Xcode installed, which is free.

HaXe on Android

To build for Android, make sure you have your device plugged in and navigate, via terminal, to the directory where you downloaded and extracted the example project. Next we type in the following command, which may take a while depending on your machine specs:

nme test "Actuate Example.nmml" android

Woot! We now have a bunch of circles running around like a bunch of crazies. Pretty easy so far.

HaXe on iOS

To build for iOS simulator navigate, via terminal, to the directory where you downloaded and extracted the example project. Next we type in the following command:

nme test "Actuate Example.nmml" ios -simulator

Again, that was pretty painless for getting it onto multiple devices in a short time.

But Wait, There's More

So you have the example project on Android and iOS, but you want to target more platforms such as windows mobile, a web page, or webOS? All you have to do is change the target device name and it should export the project accordingly.

nme test "Actuate Example.nmml" flash
nme test "Actuate Example.nmml" ios -simulator
nme test "Actuate Example.nmml" webos
nme test "Actuate Example.nmml" android
nme test "Actuate Example.nmml" windows
nme test "Actuate Example.nmml" mac
nme test "Actuate Example.nmml" linux
nme test "Actuate Example.nmml" html5