{% youtube %}https://youtu.be/pne0rSB0_Lo{% endyoutube %}
This section shows how to build and test RoboVM iOS applications using IntelliJ IDEA. It will explain how to use IntelliJ to activate your commercial license, create new iOS projects, build an iOS application and then compile, test and debug using the tools and interfaces you are already familiar with.
With all the prerequisites out of the way, proceed to download the latest IntelliJ version from https://www.jetbrains.com/idea/download/. The IDE comes in two different flavors, Ultimate and Community, and both work perfectly with the RoboVM plugin.
There are three important steps that must be completed in order to properly setup IntelliJ for working with RoboVM.
-
IntelliJ MUST be run using Oracle’s Java SE 7 JDK or later. Apple’s Java 6 JVM will not work. The easiest way to ensure this is to download IntelliJ IDEA with JetBrain's custom JDK bundled. This is available for EAP builds builds. Starting with IntelliJ IDEA 14.1.4, you can also switch the SDK within IntelliJ IDEA.For release builds, locate your IntelliJ IDEA installation folder, right-click the IntelliJ application and select Show Package Contents. Open the
Info.plist
file located inContents
by double clicking it and make sure the JVMVersion entry under JVMOptions is set to 1.7+. Note that this alternative will break the signature of the application. OS X will prompt you to allow the app to run each time you launch IntelliJ IDEA. -
The default max heap setting for IntelliJ is set too low by default. In order to increase it you need to change the -Xmx setting used when launching IntelliJ. Locate your IntelliJ installation folder, right-click the IntelliJ application, and select Show Package Contents. Copy the
idea.vmoptions
file located inContents/bin
to~/IdeaIC14/
(note that the version might have changed). Open the copy in a text editor and change the -Xmx value to 1G or more. -
You can now configure a JDK by navigating to Configure > Project Defaults > Project Structure on the Welcome to IntelliJ IDEA dialog. Select SDKs in the left pane, click the plus sign, and choose JDK. IntelliJ will be smart enough to find your JDK installations, so just select the one you want to use.
With IntelliJ setup, you are ready to install the RoboVM IntelliJ plugin. Open the IntelliJ Preferences and select the Plugins entry in the pane to the left. Click the Browse repositories button at the bottom, and search for RoboVM.
NOTE: You can use a nightly build by downloading the latest IDEA plugin from http://download.robovm.org/. Then, instead of clicking Browse repositories on the plugins dialog, use the Install plugin from disk option and navigate to the downloaded jar file.
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 IntelliJ RoboVM menu and enter your license key.
Creating a new iOS project from within IntelliJ is just like any other project type. Selecting File > New > Project will open the dialog shown below, where you should choose RoboVM iOS App without storyboards.
The next two steps in the project wizard will allow you to customize your project with the following values:
- Package Name, e.g. com.mycompany.myapp
- Main Class Name, e.g. Main
- Application Name, the name used when your app is installed to an iOS device or simulator
- Application Id, a unique identifier, usually your package name
- Build System, the tool to use for managing builds and dependencies
Finally, specify your Project Name and Project Location.
In order to run your newly created iOS application, you must first setup a Run Configuration. Navigating to Run > Edit Configurations, and clicking the '+' to add a RoboVM iOS config, will open the dialog shown below.
You can create multiple configurations, one for each device and simulator you want to debug on. After closing the dialog, select the Run menu and choose the configuration you just created.
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 IntelliJ at your disposal: you can set breakpoints, step into/out/over source lines, inspect and set variables and even use IntelliJ's Evaluate Expression view.
Once you are happy with your app and have tested it on multiple devices, it is time to publish it to the App Store. For this you need to create an iOSApplication Archive (IPA). You can do so from within IntelliJ by selecting Build > Create IPA.
Specify the output directory, your signing identity and provisioning profile and click OK. 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.