Mathjax javascript librry setup

Using Scala for iOS Development

RoboVM

The RoboVM project is putting a JVM on iOS devices. RoboVM is a compiler that translates Java bytecode into native ARM or x86 code. Apps run directly on the CPU. No interpreter or virtual machine involved. The standard classes (java.lang., java.util., etc) included in RoboVM are based on Android’s runtime, so RoboVM promises the support writing code once that can be run on both iOS and Android devices.RoboVM includes a Java to Objective-C bridge. Bridged Objective-C objects can be used just like any other Java object. Much of UIKit is already bridged and more frameworks will follow.

Installation

Trying out RoboVM

I followed the tutorial for using RoboVM with Eclipse on the RoboVM web site. It build and ran just fine on the iOS Simulator

I also tried the tutorial for using RoboVM from the command line, and that worked fine too, as long as I was sure to use the correct path for the jar files on the command line.

Scala on RoboVM

  • The Scala on iOS blog entry describes using Scala with RoboVM
  • I tried the tutorial using the sbt-robovm plugin, but the compile fails with the error “(*:iphone-sim) java.lang.IllegalArgumentException: Path /Users/billb/Applications/robovm is not a valid RoboVM install directory: version mismatch (expected: null, was: 0.0.4)“. This error is occurring inside the RoboVM code (in Config.java) …. it does not appear to be a problem with the sbt-robovm plugin
  • You can also use a development version of RoboVM by:
    • clone the RoboVM repository
    • follow the instructions at Hacking on RoboVM to build RoboVM from scratch.
    • use mvn javadoc:javadoc and mvn javadoc:aggregate to create JavaDoc documentation for RoboVM
    • And set the ROBOVM_DEV_ROOT environment variable to point to the root directory of a full RoboVM source tree
  • Once I did this, I got a different validation error from Config.java: “(*:iphone-sim) java.lang.IllegalArgumentException: Path /Users/billb/Documents/BillsDev/scaladev/robovm is not a valid RoboVM source tree: rt/target/robovm-rt-null.jar missing or invalid"
    • Yes, because when I built RoboVM from source, the release got names 0.0.6-SNAPSHOT, and the jar file was named “rt/target/robovm-rt-0.0.6-SNAPSHOT.jar”
    • So I just manually renamed the file to rt/target/robovm-rt-null.jar … and this worked!
  • So I got the Scala on iOS to run, using the sbt-robovm plugin … through hacking.
  • There is pretty much zero documentation for RoboVM … its “read the code”.

JavaFX, libgdx and Games

Observations

  • The technology is very new and not well documented. There is a lot of digging ans assembly by the user required. This makes it a challenge for a real newbie like me.
  • I can’t get RoboVM and Scala working together in Eclipse. There must be some way to combine the RoboVM Eclipse Plugin features with the Scala IDE features, but I have no idea how to do it.
  • The best bet seems to be using the [sbt-robovm plugin](, but I did have issues getting it working. (See above)
  • What RoboVM provides is a very “thin” veneer on the iOS Framework APIs… this means you are basically “writing Objective-C in Java or Scala”. You have to have a good knowledge of iOS programming to write applications. There are no higher level abstraction on top of the iOS Frameworks. SO this really limited the value of being able to use Java or Scala.

Other Notes

  • Sebastian Nozzi has a few useful Scala Gists that are good for new Scala developers, including an example of using RoboVM.

Comments