PythonSwiftLink / SwiftJava

Swift to Java Bridge
Other
0 stars 0 forks source link

Port SwiftJava as an extension to the existing PSL protocols #1

Open PythonSwiftLink opened 5 months ago

PythonSwiftLink commented 5 months ago

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

PythonSwiftLink commented 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..

PythonSwiftLink commented 1 month ago

https://medium.com/@SCADE/swift-for-android-how-to-use-swift-crypto-with-android-studio-5dd7ecaf47ac

https://www.swift-android.com/getStarted