In this section you'll learn how to install Eclipse, install the RoboVM Eclipse plugin, activate your commercial license, and create and run your first iOS application.
With all the prerequisites out of the way, proceed to download a recent Eclipse build from https://www.eclipse.org/downloads/. Eclipse comes in many different flavors, the Eclipse IDE for Java Developers package is sufficient for RoboVM development. Simply download the package, decompress it, and copy the resulting folder int /Applications/
.
There are some important steps that must be completed in order to properly setup Eclipse for working with RoboVM.
-
Eclipse MUST be run using Oracle’s Java SE 7 JDK or later. Apple’s Java 6 JVM will not work. Running Eclipse itself in Java 7 is not the same as adding a Java 7 JRE to Eclipe's Installed JREs dialog in Preferences. To check which Java version Eclipse is running in go to Eclipse -> About Eclipse, then click Installation Details and open the Configuration tab. Find the
java.version
property and make sure it is 1.7 or higher. -
The default max heap setting for Eclipse may be too low. In order to increase it you need to change the -Xmx setting used when launching Eclipse. To do this locate your Eclipse installation folder, right-click the Eclipse file and select Show Package Contents. Open the
eclipse.ini
file located inContents/MacOS
in a text editor and change the -Xmx value to 2G or more. Restart Eclipse.
With Eclipse installed and setup, you can now install the RoboVM Eclipse plugin by selecting Install New Software from the Eclipse Help menu, enter the following update site into the Work with field and click Next:
http://download.robovm.org/eclipse/
Follow the on-screen instructions until installation is complete and restart Eclipse.
NOTE: You can use a nightly build by using
http://download.robovm.org/nightlies/eclipse/
as the software site instead of the one listed above.
You have to active the license for use on your computer. Activating the license will enable the features you purchased. Select License Manager from the Eclipse RoboVM menu and enter your license key.
You can now create your first RoboVM project! Select File -> New -> RoboVM iOS Project. The project wizard will appear:
Perform these steps to define your project:
- Fill in your Project Name
- From the Template combobox select RoboVM iOS App without storyboards
- Specify the package and name of your Main Class, e.g. com.mycompany.myapp.Main
- Specify the App Name. This is the name used when your app is installed to an iOS device or simulator
- Specify the App ID. This must be a unique identifier, usually your package name
- Click Finish
You can run or debug a RoboVM app on either the simulator or a provisioned device connected via USB, directly from within Eclipse. Right click the project in the package or project view, select Run As or Debug As, then select which platform you want to run/debug the app on.
NOTE: The first time you run your application on the simulator or the device, RoboVM has to compile not only the classes of your app, but also any runtime classes required by your code. This can take some time. The next time you compile your app, RoboVM will only recompile the classes that have changed since the last compilation. You can view RoboVM's progress in the RoboVM console view.
When starting you app in debug mode, you have the full debugging tools of Eclipse at your disposal: you can set breakpoints, step into/out/over source lines, inspect and set variables and even use Eclipse's display view
RoboVM supports running and debugging JUnit tests for console and simulator apps. Let's add a new unit test to our project.
Create a new source folder which will contain all your unit tests by right clicking the project and selecting File -> New -> Source Folder. In the dialog, enter src/test/java
, then click Finish. Copy the following source code to your clipboard, then select the src/test/java
folder in Eclipse and paste the clipboard contents.
import static org.junit.Assert.*;
import org.junit.Test;
public class MyIOSUnitTest {
@Test
public void test() {
System.out.println(System.getProperty("os.name"));
System.out.println(System.getProperty("os.arch"));
fail("Not yet implemented");
}
}
We have not yet added JUnit as a dependency to our project, so you will see compilation errors. Move your cursor somewhere on the line that reads @Test
of the MyIOSUnitTest.java
file, then press CMD+1
and select Add JUnit 4 libray to the build path.
You can now run this unit test by right clicking the MyIOSUnitTest.java
file in Eclipse, then select Run As or Debug As, followed by iOS Simulator JUnit Test.
Once your are happy with your app and have tested it on multiple devices, it's time to publish it to the App Store. For this you need to create an iOSApplication Archive(IPA). To do so from within Ecipse, right click your project, then select RoboVM Tools -> Package for Ad-hoc/App Store distribution....
Specify the output directory, your signing identity and provisioning profile and click Finish. You will find a file with the extension .ipa
in the output directory, which is ready to be uploaded to iTunes Connect via the Application Loader.
NOTE: Please refer to Apple's documentation on how to submit your application.