RoboVM comes with an extensive set of samples, available on Github. The samples are composed of ports of Apple's sample apps as well as apps we created ourselves.
In this article, we'll walk you through getting the samples, compiling and running them with Eclipse, IDEA, Maven and Gradle.
NOTE: Please make sure you have installed all prerequisits as outlined in the "Getting Started" guide!
Name | Description | Demonstrates |
---|---|---|
AppPrefs | Port of Apple's AppPrefs sample | How to display your app's user configurable options (preferences) in the "Settings" system application. |
BatteryStatus | Port of Apple's BatteryStatus sample | How to use the battery status properties and notifications provided via the iOS SDK. |
ContractR | Sample app for iOS, Android and JavaFX. | How to share code between an iOS and Android app using native UI in both apps. The iOS and Android projects are using a shared core project which holds the Model part of the Model View Controller pattern. Please note that the code in these projects are in need of clean-up, so please let us know when you find strange things. Please also feel free to improve this sample and let us know. |
CurrentAddress | Port of Apple's CurrentAddress sample | How to use MapKit, displaying a map view and setting its region to current location. |
DateCell | Port of Apple's DateCell | How to display formatted date objects in table cells and use UIDatePicker to edit those values. |
DocInteraction | Port of Apple's DocInteraction sample | How to use UIDocumentInteractionController to obtain information about documents and how to preview them. |
Footprint | Port of Apple's FootPrint sample | How to take a Latitude/Longitude position and project it onto a flat floorplan. |
HelloWorld | Port of Apple's HelloWorld sample | How to use a keyboard to enter text into a text field and how to display the text in a label. |
LaunchMe | Port of Apple's LaunchMe sample | How to implement a custom URL scheme to allow other applications to interact with your application. Shows how to handle an incoming URL request by overriding UIApplicationDelegate.openURL to properly parse and extract information from the requested URL before updating the user interface. |
LocateMe | Port of Apple's LocateMe sample | How to get the user's location and how to track changes to the user's location. |
MessageComposer | Port of Apple's MessageComposer sample | How to use the Message UI framework to compose and send email and SMS messages from within your application. |
MoviePlayer | Port of Apple's MoviePlayer sample | How to use the Media Player framework to play a movie from a file or network stream, and configure the movie background color, playback controls, background color and image, scaling and repeat modes. It also shows how to draw custom overlay controls on top of the movie during playback. |
PhotoScroller | Port of Apple's PhotoScroller sample | How to use embedded UIScrollViews and CATiledLayer to create a rich user experience for displaying and paginating photos that can be individually panned and zoomed. CATiledLayer is used to increase the performance of paging, panning, and zooming with high-resolution images or large sets of photos. |
QuickContacts | Port of Apple's QuickContacts sample | How to use the Address Book UI controllers and various properties. Shows how to browse a list of Address Book contacts, display and edit a contact record, create a new contact record, and update a partial contact record. |
Regions | Port of Apple's Regions sample | How to monitor regions, significant location changes, and handle location events in the background on iOS. |
StreetScroller | Port of Apple's StreetScroller sample | How to subclass a UIScrollView and add infinite scrolling. |
TableSearch | Port of Apple's TableSearch sample | How to use UISearchController. A search controller manages the presentation of a search bar (in concert with the results view controller’s content). |
Tabster | Port of Apple's Tabster sample | How to build a tab-bar based iOS application. |
Teslameter | Port of Apple's Teslameter sample | How to create a Teslameter, a magnetic field detector, with the use of the Core Location framework and display the raw x, y and z magnetometer values, a plotted history of those values, and a computed magnitude (size or strength) of the magnetic field. |
TheElements | Port of Apple's TheElements sample | How to create an application that provides access to the data contained in the Periodic Table of the Elements. This sample provides this data in multiple formats, allowing you to sort the data by name, atomic number, symbol name, and an element's physical state at room temperature. TheElements is structured as a Model-View-Controller application. |
Touches | Port of Apple's Touches sample | How to handle touches, including multiple touches that move multiple objects with UIResponder and UIGestureRecognizers. |
UICatalog | Port of Apple's UICatalog sample | How to create and customize user interface controls found in the UIKit framework, along with their various properties and styles. |
VideoRecorder | Port of Apple's VideoRecorder sample | How to create a custom UI for the camera variant of the UIImagePickerController and how to programmatically control video recording. |
To download the samples, you'll need to clone them via git:
git clone https://github.com/robovm/robovm-samples
After you successfully cloned the samples, move on to the section for your prefered development environment:
- Eclipse
- IntelliJ IDEA
- Maven
- Gradle
You can import the samples into Eclipse either via m2e/Maven or Gradle.
- Go to File -> Import....
- Select Maven -> Existing Maven Projects.
- Set Root Directory to the directory you cloned the samples into (
robovm-samples/
). - Click Finish.
You can now proceed to compile, run and debug the samples, as outlined in the Getting Started Guide for Eclipse.
Before you can import the samples via Gradle, you need to install the Gradle Integration for Eclipse. You can install it the the Eclipse Market Place (Help -> Eclipse Market Place...).
After installing the plugin, you can proceed as follows:
- Go to File -> Import....
- Select Gradle -> Gradle Project.
- Set Root folder to the directory you cloned the samples into (
robovm-samples/
). - Click Build Model.
- Check the checkbox next to the
robovm-samples
entry. All other projects should be selected as well. - Click Finish.
You can now proceed to compile, run and debug the samples, as outlined in the Getting Started Guide for Eclipse.
You can import the samples into IntelliJ IDEA either via Maven or Gradle.
- Go to File -> Open.
- Select the
pom.xml
file in the root directory fo the samples. - Click OK.
You can now proceed to compile, run and debug the samples, as outlined in the Getting Started Guide for IntelliJ IDEA.
- Go to File -> Open.
- Select the
settings.gradle
file in the root directory fo the samples. - In the Gradle dialogue, keep all settinsg as they are and click OK.
You can now proceed to compile, run and debug the samples, as outlined in the Getting Started Guide for IntelliJ IDEA.
In the root directory, do:
mvn clean install
This will compile all samples. Next, switch into a sample directory and execute one of the following:
# to launch on an IPhone simulator
mvn robovm:iphone-sim
# to launch on an IPad simulator
mvn robovm:iphone-sim
# to launch on a connected device
mvn robovm:ios-device
See the RoboVM Maven Plugin documentation for more information.
In the root directory, do:
./gradlew build
This will compile all samples. Next, switch into a sample directory and execute one of the following:
# to launch on an IPhone simulator
../gradlew launchIPhoneSimulator
# to launch on an IPad simulator
../gradlew launchIPadSimulator
# to launch on a connected device
../gradlew launchIOSDevice
See the RoboVM Gradle Plugin documentation for more information.
ContractR is a special sample that shows you how to create a cross-platform app for both iOS and Android, sharing large portions of the code through a core
project.
You can open ContractR in both Eclipse or IntelliJ IDEA. However, in Eclipse, you will not be able to work with the Android project, as Android development is limited to IntelliJ IDEA or Android Studio.
In Eclipse, import ContractR via the Maven pom.xml
file in the root of the project.
In IntelliJ IDEA, import ContractR via the Gradle settings.xml
file in the root of the project.