sbt-robovm is a plugin for the Scala build tool that aims to make it as simple as possible to compile Scala (and Java) code to binaries for iOS, linux, and OSX using RoboVM
First, add the plugin to your project by appending addSbtPlugin("org.roboscala" % "sbt-robovm" % "1.12.0")
into the project/plugins.sbt
file. The file name (not extension) may actually be different, but such is the convention.
The plugin's version is in sync with the RoboVM version it uses, so it should always be clear which RoboVM is being used.
All you have to do to use the plugin, is to add iOSRoboVMSettings
key (or nativeRoboVMSettings
if you are creating a native project)
to your build.sbt
file.
If you are creating a multi-project build, prepend that to your settings Seq:
lazy val myproject = Project(id = "myproject", base = file("myproject"), settings = iOSRoboVMSettings ++ Seq(
/* More settings */
))
There are different tasks defined for iOS and native console projects.
robovmLicense
iphoneSim
and ipadSim
simulator
robovmSimulatorDevice
setting.device
robovmPreferredDevices
task.ipa
simulatorDevices
native
nativeBuild
native
, but does not execute the binary.As with tasks, there are some settings that are only meaningful in iOS projects. Some settings are actually implemented as tasks.
robovmConfiguration
Either[File,Elem]
Left(file("path-to-your/robovm.xml"))
Right(<config> ... </config>)
robovmProperties
Either[File, Map[String, String]]
Left(file("path-to-your-file"))
Right(Map("some-key" -> "some-value", ...))
app.name
- Value of name
sbt keyapp.executable
- Name of executable derived from name
sbt keyapp.mainclass
- Fully specified main class of your application, either detected or specified in mainClass
keyrobovmTarget64bit
Boolean
true
if your device is newer and has a 64bit processorrobovmHome
Config.Home
robovmInputJars
Seq[File]
fullClasspath
, which is in most cases correct. You may want to override this if you want to modify the compiled classes first somehow (for example when using ProGuard).robovmVerbose
Boolean
robovmDebug
Boolean
robovmLicense
task to enter yoursrobovmDebugPort
robovmDebugPort
Int
robovmDebug
)robovmProvisioningProfile
Option[String]
robovmSigningIdentity
Option[String]
robovmSimulatorDevice
Option[String]
simulator
tasksimulatorDevices
task to list all installed devicesrobovmSkipSigning
Option[Boolean]
Some(true/false)
overrides default signing behavior and allows you to test without proper certificates and identitiesrobovmPreferredDevices
Seq[String]
robovmIBScope
Scope
interfaceBuilder
command operates. Defaults to ThisScope
.Line numbers will be enabled automatically when the license is entered (see robovmLicense
task).
To use the RoboVM debugger, prefix your task invocations with debug:
(example: $ sbt myproject/debug:ipadSim
).
This sets the scope to the Debug
configuration, in which the debugger is enabled and the debug port is set, by default to 5005.
Running with the debugger enabled will allow you to connect to a running application with a java debugger.
$ sbt debug:ipadSim
)Application execution will pause before your main
method and wait for the debugger to attach. Then it will continue normally.
This plugin offers a basic integration with XCode's Interface Builder. There are some excellent tutorials on how to use IB with IntelliJ on RoboVM website. Getting familiar with them is recommended, since the workflow in sbt is similar.
In the core of this feature is an interactive interfaceBuilder
command.
Run the command inside your iOS project, it will generate XCode project and open it in the Interface Builder.
Then it will watch your code sources and when any of them change, it will recompile the project and update the XCode project accordingly.
XCode will show new IBOutlet
s and IBAction
s very shortly after that.
You will also notice, that the prompt in the sbt console will change to "interfaceBuilder >".
That notes that you are in a special mode, where the interfaceBuilder
command is still running, but you can still run
any commands/tasks as usual, so you can, for example, run the ipadSimulator
task to quickly view your changes on device.
Pressing enter, without any command, will exit the interfaceBuilder
mode and you will be back to standard sbt prompt.
Because interfaceBuilder
is a command and not a task (for technical reasons), it can not be scoped.
Therefore, doing something like myProject/interfaceBuilder
will not work.
To work around this, use project myProject
command first, to switch active project to that and then run interfaceBuilder
.
If you need even more granular scoping, use the robovmIBScope
setting.
robovmSigningIdentity/Profile
keys to automatically use the distribution pair when building an ipa:
robovmProvisioningProfile := Some("name of development profile"),
robovmSigningIdentity := Some("name of development identity"),
robovmProvisioningProfile in ipa := Some("name of distribution profile"),
robovmSigningIdentity in ipa := Some("name of distribution identity")
If you need to make modifications to the plugin itself, you can compile and install it locally:
$ git clone git://github.com/roboscala/sbt-robovm.git
$ cd sbt-robovm
$ sbt publish-local
When testing your changes, it is useful to publish locally with different version than what is officially used. That is because if you have already used the official version, your testing projects will most likely use that and not your modified version. To workaround that, change in sbt-robovm's build.sbt:
version := roboVMVersion.value,
to
version := roboVMVersion.value + "-YOUR_SUFFIX",
and in the project/plugins.sbt of your (testing) project, instead of standard installation:
// Necessary only when testing with RoboVM snapshot build, such as 1.11.1-SNAPSHOT
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("org.roboscala" % "sbt-robovm" % "1.12.0-YOUR_SUFFIX" changing())
Unless you need to use the SNAPSHOT version of RoboVM, it is easier to work with stable version, because for SNAPSHOT dependencies, sbt has to check for new version each run, which adds latency to testing.
However, when working on the plugin, you want it to be "redownloaded" each time it changes, and the changing()
in addSbtPlugin
line does exactly that. But don't worry, thanks to it being installed/published locally, the latency of these checks is negligible.
Reporting any issues you encounter helps. If you want to help improving the plugin, feel free to make a PR.
libgdx-sbt-project.g8 (Uses older version)