Hi folks
After many trials and tribulations I managed to get robovm to compile as, and function as a static library (woohoo!)
I'm not sure how many here are interested in doing it, but I thought I should give back what I've learnt as a brief outline.
Firstly, Simon's work
here has been very useful. It made things much easier than it could have been. But it wasn't enough for us as we wanted a robovm app to be a 'real' static library, that is, it doesn't seek to override the xcode app's main method.
To do that, we needed to modify the guts of robovm.
You'll need to add a method initialise robovm on demand.
This method will call a modified version of bc.c's main method. I called it customInitHook
For my setup, I created a simple file called custom_init that took in the app path and called bc's customInitHook.
customInitHook is the same as bc.c's main, except that it calls a special version of rvmRun, which doesn't invoke the Java app's main method.
Once the vm has been initialised, you can use Simon's bridge.cpp to call/pass over your stuff. Also, you can't really use jni in bridge.cpp, as the classloader is not there. There's a workaround, but I am not actively using it, since rvm's own methods (like rvmGetClassMethod) are good enough.
Note that for the static library to function properly, it can't declare bc.c's main mtd, since you can't have 2 main methods defined in an app. So it has to be renamed/commented out.
Another thing to take note of is the "gc.h" includes. Simon noted that it didn't seem to cause any problems, but that wasn't the case here. With "gc.h" commented out, the entire gc mechanism wasn't working at all, and the app would crash at random spots. Lots of time was spent debugging here.
In Simon's post, he also outlined a whole list of linker flags to be included in Xcode. That wouldn't have worked well for us, too many includes and configs for the host app, if you were to package off the static lib to someone else. Furthermore, the host app shouldn't need to know anything about robovm.
So we compiled everything into 1 static library. Robovm's .a files + our app files, and packaged it into a Framework.
You will still need to force_load it, for robovm-rt and native libraries, but it works fine, and our linker flags were cut down drastically, also it fixes the gc.h include issue in Xcode.
To pass data between xcode host app land and javaland, you'll want to convert your NSObject to long long and send it to Java. Then in Javaland, you'll want to use ObjCObject.toObjCObject(NSObject.class, handle).
Well that's about it, it works wonderfully and I'm always impressed when I dive into robovm's guts. Niklas is awesome(!!!). There are some niggling issues like certain javaland crashes would just cause the app to die without any traces, making it hard to debug, but so far so good!