Scala on iOS using Avian

IphoneIosScalaJvmAvian

Iphone Problem Overview


There is a relatively-new lightweight JVM called Avian that can produce executables for iOS targets.

There isn't too much documentation on the website (and not much can be found searching with Google). I was wondering if anybody was aware of a step-by-step tutorial on how to get a basic Scala program running on iOS, using Avian.

Iphone Solutions


Solution 1 - Iphone

Another alternative JVM to iOS compiler is RoboVM. Although it is at an early stage, it looks quite promising, with examples on how to compile Scala for iOS.

EDIT This was an old answer, valid at that time, but, as @JamesMoore points out, RoboVM is no more. What looks very promising now, and may well be the way to run Scala code in iOS in the near future is Scala Native

Solution 2 - Iphone

Compiled Scala sources are completely standard class files. You should be able to follow the instructions (look for “Embedding”) on the website without large changes, just treat scala-library.jar as a dependency of your code.

I managed to bootstrap the complete compiler and the standard library running on Avian a few days ago.

Some parts might still be a bit rough around the edges, e. g. there is one mandatory fix which will be part of the next release of Scala (2.10.1) but is not in 2.10.0. If you want to play with it right now, you need to use a nightly build until 2.10.1 is released.

If you encounter any additional issues, please report them!

Solution 3 - Iphone

I may not need it anymore, now that Oracle is making JavaFX open-source on iOS and Android!

EDIT: Oracle updated the article to announce that they will not release a JVM, so it looks like JavaFX+Avian may be the way to go.

Solution 4 - Iphone

Running Java byte code on iOS (not-rooted) is not only running that or those JVM. As far as I understand iOS memory management doesn't allow executable memory pages to be writable in user mode. That basically prohibits any JIT compilation. So even if it's possible to run some compiled (either from Java or Scala) classes on specific Java VM I would carefully check how this VM supports Ahead-Of-Time compilation in order to be runnable on iOS. As I have seen Avian AOT works well on a desktop. For iOS you will have to check it yourself, although the project looks promising in AOT area.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEduardoView Question on Stackoverflow
Solution 1 - IphoneEduardoView Answer on Stackoverflow
Solution 2 - IphonesocView Answer on Stackoverflow
Solution 3 - IphoneEduardoView Answer on Stackoverflow
Solution 4 - IphonevladimirView Answer on Stackoverflow