haxe openfl on mac – quick start guide for mobile development

Haxe is a cross platform toolkit and supports cross compilation in many different languages. It is a pretty good choice for game and app development which are required to run on multiple platforms. OpenFL is a free and open source software framework and platform for the creation of multi-platform applications and mobile games in haxe. Here is a quick start guide for setting up haxe and openfl on mac on OS X El Capitan.

Prerequisite packages

These packages must be installed on your system before you proceed.

  1. Java JDK
  2. Android SDK
  3. Android NDK
  4. Apache Ant

Install haxe

First download haxe dmg (OS X installer) and install the haxe on your mac. Click on the downloaded dmg and follow the install instructions. Once installed you should see very likely see haxelib at location /usr/local/bin/haxelib and haxe at location /usr/local/bin/haxe. The installer installs haxe files at these locations (for OS X Yosemite):


All other haxe libraries you install later will go in directory /usr/local/lib/haxe/. Now type haxelib on command line to verify installation.

$ haxelib
Haxe Library Manager 3.3.0 - (c)2006-2016 Haxe Foundation
  Usage: haxelib [command] [options]
    install   : install a given library, or all libraries from a hxml file

Install openfl

Install openfl and openfl-samples using haxelib.

$ haxelib install openfl
$ haxelib install openfl-samples

Setup openfl

Use the following command for openfl setup:

$ haxelib run openfl setup

openfl setup will also install lime and couple of other packages. When it asks you “Do you want to install openfl command?”, you can enter “y” as shown below:

$ Do you want to install the "openfl" command? [y/n/a] ? y

setup openfl for android

Now we will setup openfl for android. Run the following command:

$ openfl setup android
Download and install the Android SDK? [y/n/a] ? n
Download and install the Android NDK? [y/n/a] ? n
Download and install Apache Ant? [y/n/a] ? n

Path to Android SDK []: /Users/pkjain/Documents/install/android-sdk-macosx 
Path to Android NDK []: /opt/AndroidNDK
Path to Apache Ant []: /usr/local/bin/ant

Provide the appropriate path locations for Android SDK, Android NDK and Apache ant.

Create openfl sample project

Now we use openfl create command to list the available samples.

$ openfl create
You must specify a template when using the 'create' command.
 Usage: openfl create project (directory)
 Usage: openfl create extension (directory)
 Usage: openfl create  (directory)

 Available samples:

  * AddingAnimation
  * CompareBitmapData
  * DisplayingABitmap

Now create one of these samples. We’ll pick NyanCat.

$ openfl create NyanCat

This will create NyanCat directory and you should be able to see project.xml file, Sources directory, etc. in this directory.

Running the sample project

You can build and run the sample project on a connected android mobile device (make sure USB debugging is enabled on your mobile) using these commands:

$ openfl test android --verbose

test command will build the apk, install it on android device and also call adb logcat command.
Here is how it looks when it runs on android:

Note that you also also run this projects for other targets like flash, ios, html5, mac, etc.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments