Using the default Xcode iOS App with SwiftUI, we can invoke Java code.
The following steps are needed:
- Build GraalVM from source (GraalVM head works)
- Build OpenJDK Mobile static JDK libs (libjava.a, libnet.a etc)
- Combile all static JDK libs in one libjdk.a
- Annotate java code that needs to be exposed with @CEntryPoint
- Use Gluon Substrate and GraalVM native-image to compile Java code into
an object file. This object file include most of the JVM.
- Compile required C code (sources in Gluon Substrate) that needs to work with GraalVM SubstrateVM.
- Combine the Java-based object file with the additionally required C code
into another library, liboak.a
- Add libjdk.a and liboak.a to the XCode project
- Add graal_isolate headers to the XCode project
- From Swift code, create Isolate and invoke annotated @CEntryPoint code.