Due to popular demand I have decided to release the source code for the BrickBreaker JavaFX sample on iOS demo I showed off last week. Initially I had intended to wait until the JavaFX font stuff had been open-sourced but some people seem very eager to try this out for themselves so here we go.
First of all we need to make sure you have all the prerequisites installed:
- Get Xcode 4.6.2 from the App Store.
- Download and install JDK 8 build b90. The commands below assume it ends up in /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk.
- Install LLVM 3.2 to /opt/llvm:
1$ curl -O 'http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-apple-darwin11.tar.gz'<br />$ sudo tar xvfz clang+llvm-3.2-x86_64-apple-darwin11.tar.gz -C /opt<br />$ sudo ln -s /opt/clang+llvm-3.2-x86_64-apple-darwin11 /opt/llvm<br />$ rm -f clang+llvm-3.2-x86_64-apple-darwin11.tar.gz<br />
- Install the latest RoboVM nightly build to /opt/robovm:
1$ curl -O 'http://download.robovm.org/nightlies/robovm-0.0.2-SNAPSHOT-20130520_0201.tar.gz'<br />$ sudo tar xvfz robovm-0.0.2-SNAPSHOT-20130520_0201.tar.gz -C /opt/<br />$ sudo ln -s /opt/robovm-0.0.2-SNAPSHOT /opt/robovm<br />$ rm -f robovm-0.0.2-SNAPSHOT-20130520_0201.tar.gz<br />
You should now be able to run the BrickBreaker sample:
- Download the BrickBreaker sources:
1$ curl -O 'http://download.robovm.org/BrickBreaker.zip'<br />$ unzip BrickBreaker.zip<br />
- Compile the Java sources and copy images:
1$ cd BrickBreaker<br />$ mkdir bin<br />$ find src -name '*.java' -print | xargs javac -d bin -bootclasspath /opt/robovm/lib/robovm-rt.jar -cp /opt/robovm/lib/robovm-objc.jar:/opt/robovm/lib/robovm-cocoatouch.jar:lib/openjfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/ext/jfxrt.jar<br />$ rsync -r --include '*.png' src/ bin/<br />
- Compile the class files to native code using RoboVM and launch the app on the iOS Simulator:
1$ /opt/robovm/bin/robovm -verbose -properties robovm.properties -config robovm.xml -arch x86 -run -ios-sim-family ipad<br />
After some time (the first build will take quite a lot of time) the BrickBreaker app should appear in the iOS Simulator. If you want to try this out on your iDevice (an iPad is recommended because of the screen size required by the app) just plug it into your Mac and run:
$ /opt/robovm/bin/robovm -verbose -properties robovm.properties -config robovm.xml -run<br />
BrickBreaker.zip also contains an Eclipse project. Here’s a link to the Eclipse update site for the nightly build of the RoboVM plug-in: http://download.robovm.org/nightlies/eclipse/