1

By checking the Codename One website and ParparVM Github, its guide only show how to build the Java (with Java Main function entry point) into the native executable/app (iOS), but I can't find any guide to build/compile Java into iOS share library (either in C source or binary, as long as can be reused by swift/objective-C from iOS app).

So are we able to do so? is there any guide for that?

Sam YC
  • 10,725
  • 19
  • 102
  • 158

1 Answers1

1

It wasn't designed for that purpose so it probably won't work well for it. There are some inherent design decisions that would make it very difficult to get ParparVM to work with a library. Two big ones:

  • The GC needs to work with roots and would have a hard time collecting without full control of the app

  • The code generated looks "awful". Method names translate to very long function names in C with a very convoluted syntax to allow all sort of VM edge cases such as covariance

I suggest you look at J2ObjC. I haven't checked it out in ages but it was designed exactly with this use case in mind. It doesn't have a "real" GC but that might be OK with ARC. It works with your sources and produces libraries that look a bit more "natural" on iOS.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • thanks, we tried J2ObjC before, but it can't work for Java library without source file, that's why we are more looking for Ahead-of-time compilation approaches. – Sam YC Jul 28 '20 at 04:47