Thursday 13 October 2011

Game of Life HaXe & NME on iOS

For the last few days I have been playing around with trying to get the game of life sample from my previous post working on the iPhone using haXe with NME.

In theory NME should do all the heavy lifting for you so that it should be as simple as running:

[code lang="text"]
haxelib run nme build nmebuild.nmml ios

[/code]

Unfortunately however when I ran this I was getting rather cryptic errors:

[code lang="text"]
Called from ? line 1
Called from InstallTool.hx line 384
Called from a C function
Called from InstallTool.hx line 70
Called from a C function
Called from installers/InstallerBase.hx line 61
Called from installers/InstallerBase.hx line 668
Called from installers/InstallerBase.hx line 762
Called from haxe/xml/Fast.hx line 59
Uncaught exception - icon is missing attribute name

[/code]

I had read from the NME documentation page that this may have been fixed in the more reccent versions of NME. So I downloaded the beta version (you could checkout from SVN too if you wish) and told haxelib that im going to be working with a development version of NME with the following command:

[code lang="text"]
haxelib dev nme /Users/mikec/Documents/NME_3.1_Beta

[/code]

Now when I try to build for ios I get success!



From there is a simple matter of opening the generated xcode project, connecting my iphone and hitting run:



I really like how easy the workflow is compared to the Adobe Air packaging system. Generating the xcode project makes things so much faster.

If I can get my hands on an Android phone next I think im going to have to have a go at getting this sample working on there too!

9 comments:

  1. If you would like to build and run your project using a single command, you can use:

    haxelib run nme test nmebuild.nmml flash
    haxelib run nme test nmebuild.nmml ios -simulator

    :)

    ReplyDelete
  2. Aye :) Really handy commands those. Is there any reason why you couldnt use "haxelib run nme test nmebuild.nmml ios" which would then cause xcode to fireup and launch to the iphone?

    ReplyDelete
  3. Going to a device requires provisioning and certificates, unlike the simulator. Most people I ask say that going straight to the device from the command-line cannot be done, but I'm sure it can. If anyone has tips (or wants to hack the install tool code) to support a device install and run, I'd love to hear it :)

    ReplyDelete
  4. Well the question is, do you go to the device via xcode or via some manual mechanism that xcode must use behind the scenes. Is it possible to execute functionality in xcdode externally? "xcode MyApplication.xcodeproj -launch iPhone" ?

    I would offer my assistance with this however I have very little xcode or osx experience :(

    ReplyDelete
  5. It is calling xcodebuild to compile the project on the command line. Maybe there are options there for installing to a device? (not on a Mac right now)

    ReplyDelete
  6. Oh it is? In which case there may well be then :) As I say I dont know much about osx, but are there any other tools out there that already do it? A quick google looks promising: http://stackoverflow.com/questions/4613367/how-to-run-an-xcode-built-app-from-the-command-line-bash

    ReplyDelete
  7. Have not used nme myself before - do you end up with an .ipa file that you want to sync to the device via iTunes? If yes then that step should be automatable (if that's a word :-) via osascript

    Something like
    osascript -e 'tell application "iTunes" to update "myappname"'

    Not sure if that helps but there you go :-/

    ReplyDelete
  8. Ok, reading more closely to the comments I think you may not be able to add to iTunes and run on device unless you do compile with a provisioning cert in some way. Maybe the simulator is the way to go until you are ready for (manual) on device deployment/testing.

    ReplyDelete
  9. It creates an xcode project which it then compiles and runs on the device. It seems like you could script it indeed

    ReplyDelete