How do I include JVM dependencies along with an iOS KMM target when deploying to iOS using RoboVM?

108 Views Asked by At

Currently writing a LibGDX app that has KMM and JVM sub-projects. They currently compile and run on desktop and Android. Now I'm trying to get it working on iOS, which will use RoboVM.

Since the app will run using RoboVM on iOS, everything (maybe not everything since I'm not sure exactly how RoboVM works) than runs on the JVM should still work. If I create a new Gradle JVM RoboVM project that acts as the iOS project, I'm able to depend on all JVM libraries, but any KMM libraries will not be there since the project is seen as a JVM project, even though the app should work on the JVM because of RoboVM.

Is there any way to specifically depend on all the KMM iOS target dependencies in the JVM RoboVM project?

The JVM RoboVM gradle project file looks like this:

plugins {
    kotlin("jvm")
    id("robovm")
}

kotlin {
    jvmToolchain(17)
}

robovm {
    archs = "thumbv7:arm64"
}

dependencies {
    api(project(":kmm_placeholder"))
}
1

There are 1 best solutions below

1
Kevin Galligan On

No. Well, probably not how you want. KMM and RoboVM are quite different. KMM produces actual apple binary that runs directly on apple devices. RoboVM is a JVM that runs on apple devices, and runs Java bytecode. I spent a fair bit of time on RoboVM back when it was still a functional product, but Xamarin shut down active development a long time ago.

I would say you should either use KMM for everything on iOS, or figure out how to use RoboVM for everything, but trying to use both together would be rather difficult. It wouldn't really make sense. Assuming you're publishing a JVM build for Android and/or desktop, just use that with RoboVM. Exporting an iOS binary from KMM could only be called from RoboVM through something like JNI or whatever RoboVM provides to talk to Objective-C.

Reading RoboVM again, maybe the "ahead-of-time" compiling makes an actual apple binary, but there wouldn't be any direct interop between that and KMM iOS binaries. They're quite different.