How are bindings to existing native frameworks generated? - MobiVM/robovm GitHub Wiki
RoboPods
If you're looking for a binding to a popular 3rd party library, it maybe already be done by the RoboPod project. For a list of current supported libraries take a look at: https://github.com/MobiVM/robovm-robopods/issues/1
bro-gen
bro-gen is a Ruby script that generates RoboVM bindings semi-automatically. You need to write a YAML mapping file for the library to generate the binding. For details head over to our fork of bro-gen which works with the current RoboVM version https://github.com/MobiVM/robovm-bro-gen
For some examples of YAML mapping files take a look at the config files for the iOS Cocoatouch or UIKit bindings in this repository https://github.com/MobiVM/robovm/tree/master/compiler/cocoatouch/src/main/bro-gen Those mappings are automatically generated with our bro-gen fork.
Tutorials
Generate Admob Bindings with bro gen Tutorial
Create bindings manually
For small to medium sized libraries it maybe feasible to write the bindings manually. For a simple example binding take a look at the bindings to the SVGgh library https://github.com/florianf/robopod-ghs-svg.
The original RoboVM documentation has a nice introduction to the binding mechanism used by RoboVm https://github.com/MobiVM/robovm/wiki/The-Bro-Java-to-Native-Bridge
Tips & Tricks
CGRect
andCGSize
method parameters should always be annotated with the@ByVal
annotation.- Bro doesn't support
float
, always use adouble
annotated with@MachineSizedFloat
Simple example
@Method(selector = "asImageWithSize:andScale:")
public native UIImage asImageWithSize(@ByVal CGSize maximumSize, @MachineSizedFloat double scale);