Description
This is a tracking issue for Android support. I've started some work locally but haven't published any of my progress yet. I've mostly been trying to figure out the bundling side of things to start off, but I have made some progress on how SwiftCrossUI can seamlessly integrate with JVM callback stuff;
JVM callback stuff
Since SwiftCrossUI apps get built as executable products, their only required interface is a main function. To integrate into an Android app, the plan is to link this user-written executable code into a library. We somehow need to implement an entry point that a Java shim can call into, and this entry point should ideally be defined and implemented seamlessly on the user's behalf.
My idea is to forward declare int main(int argc, char **argv)
in a c file within SwiftCrossUI. This forward declaration gets resolved at link time, so it gets resolved to the main
symbol that SwiftPM generates for the user's executable code. With this, SwiftCrossUI can define an androidBackendEntryPoint
function (name isn't important) that takes a java VM instance and whatever else as input, stores these inputs for later use within the backend, and then calls into the user's original entry point. I've tested all parts of this plan in a test project and they all appear to work.
Remaining tasks
- Figure out bundling (ideally without Gradle, but an initial prototype could use Gradle)
- Implement enough basic backend functionality to get the main structure of the backend figured out
Once those are completed, we can probably just merge things into main
and continue improving things from there.