Open PythonSwiftLink opened 5 months ago
Hello.java
public class Hello {
static {
System.loadLibrary("native");
}
public static void main(String[] args) {
new Hello().sayHello();
}
//native method with no body
public native void sayHello();
}
javac -h . Hello.java
output -> Hello.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Hello */
#ifndef _Included_Hello
#define _Included_Hello
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Hello
* Method: sayHello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_Hello_sayHello
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
so if javac -h produces the c .h for us.. then half the job wrapping Hello.java is already done. Rest is just a question of adding parts of SwiftJava as extensions to the existing PythonSwiftLink protocols. Then in theory the interop can be handle by the same way existing Python<->Swift interop works, and swift just acts as the c-glue..
using-jni-in-swift-to-put-an-app-into-the-android-play-store
guide-to-jni-java-native-interface
altconf-boris-bugling-cross-platform-swift