Gdx Freetype supported on iOS

I reworked the build system, again… We now generate extensions for iOS as well. I included freetype, bullet chokes my Mac, the other two extensions aren’t used that much, so i postponed including them. The magic happens in the build-mac-ios.xml file, which builds the Mac OS X natives as well as the iOS natives and dll files.

You can find the freetype iOS files here: http://libgdx.badlogicgames.com/nightlies/dist/extensions/gdx-freetype/ios/ (also included in the nightly zip). The .a file contains the native code, the .dll file contains the Java code converted to .Net, the .dll.mdb file contains the debug symbols. Using the extension works in three steps:

Modify convert.properties

We need to add the gdx-freetypes.jar to the CLASSPATH property, so any freetype Classes can be resolved during compilation of your Java code. We also need to add the gdx-freetype.dll to the IN property, so IKVM can link to that while converting your Java code to a .NET assembly. Here’s an example convert.properties file, assuming gdx-freetype.jar is in your core project’s libs folder, and gdx-freetype.dll is in your iOS project’s libs folder:

SRC =       ../my-gdx-game/src/
CLASSPATH = ../my-gdx-game/libs/gdx.jar;../my-gdx-game/libs/gdx-freetype.jar
EXCLUDE   =
IN        = -r:libs/ios/gdx.dll -r:libs/ios/gdx-freetype.dll -recurse:target/*.class
OUT       = target/my-gdx-game.dll

Add and link the native file

You’ll need to copy the libgdx-freetype.a file to your MonoTouch project’s libs/ folder. Then add it to your MonoTouch project in the solution explorer, just like you add any other file to a solution/project. Then you need to open the properties of your MonoTouch project and go to IPhone Build. For each configuration (Release|IPhone, Debug|Simulator etc.) you’ll need to modify the mtouch arguments to link to gdx-freetype, analogues to how libgdx.a and libikvm-natives.a are linked.

e.g.

-nosymbolstrip -nostrip -cxx -gcc_flags "-L${ProjectDir}/libs/ios -L${ProjectDir}/libs/ios/ikvm/bin -likvm-natives -lgdx -lgdx-freetype -force_load ${ProjectDir}/libs/ios/libgdx.a -force_load ${ProjectDir}/libs/ios/ikvm/bin/libikvm-natives.a -force_load ${ProjectDir}/libs/libgdx-freetype.a"

Add a reference to gdx-freetype.dll

You will also need to add a reference to the gdx-freetype.dll file. Right click the “References” entry in your project, select Edit References, then go to “.Net Assemblies” and find the gdx-freetype.dll. Click the add button so it appears on the right sidebar which shows you which assemblies are currently referenced.

I’ll add more extensions over the next week, bullet comes next once i’ve bought more RAM for my Mac Mini.

  • Peter

    The iOS backend seems to be tightly bound to MonoTouch.

    Nothing is built to go through GDX-JNIGEN and P/Invoke correct?

  • http://badlogicgames.com Mario

    Our native code is still generated via jnigen and called via JNI on iOS.

    However, the Java code relies on MonoTouch and IKVM.