Recently I provided example application without using any Java. This technology called Native Activity. This approach is less common in general Android application development and mostly used for games, where a custom graphics engine is used. Native Activity requires building the application infrastructure from the ground up, as Android primarily provides only a window for a graphics API layer, such as Vulkan or OpenGL. Here is my previous example.
Now I wanted to show my another example where Java is core of application. Here, the Java code calls methods written in Swift, which in turn can call back into Java. I used my own interoperability because I do not like idea of macro in official swift-java library, ton of unnecessary dependencies and its current poor instability; it crashes in runtime and until recently, it failed at compile time. As noted in swift-java readme, it is in early development state and not ready to use. So I provided quite complex example of Java use in Swift with my version of interop in my new Java-Swift example application.
I wouldn’t say swift-java is not ready to use, we just have not published stable releases yet. Lots of the functionality already works and people have been successfully using it here and there in limited fashion.
I’d really encourage collaboration on the official swift-java interop repository; we are also in the middle of splitting out a swift-java-jni repo which would not include the macros; So, overall, I’d really encourage collaboration here – swift-java should be able to meet everyone’s interop needs, and various styles of how you’d like to approach interoperability. To do that though, we need to hear the input, rather than have more one-off interop approaches – thanks in advance, and I look forward to figuring out how swift-java can be used in your use-cases as well!