Comments (6)
Hi,
Should be possible. I have to check.
FYI: At the moment I am updating sample project to do more interesting things than "hello world". To simplify Swift <-> Java communication the protobuf
will be used.
- https://developers.google.com/protocol-buffers/docs/javatutorial#writing-a-message
- https://github.com/apple/swift-protobuf
from swift-everywhere-toolchain.
I actually have an error output:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.home.hello_ndk, PID: 18004
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "objc_autoreleaseReturnValue" referenced by "/data/app/~~KqxlQwqa3TUqTqGewhdxaw==/com.home.hello_ndk-7-pMpv4TptG-2zyxuoccOw==/base.apk!/lib/x86/libHelloJNICore.so"...
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at com.home.helloNDK.SwiftLib.<clinit>(SwiftLib.java:6)
at com.home.helloNDK.MainActivity$1.onClick(MainActivity.java:54)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
from swift-everywhere-toolchain.
Wow that's amazing news !
from swift-everywhere-toolchain.
The "Protocol buffers" example added to https://github.com/vgorloff/swift-everywhere-samples repository.
Example shows how to send/receive complex data to/from Kotlin/Swift.
from swift-everywhere-toolchain.
This looks great! I'll give it a try as soon I can :)
I noticed your testNetworking() function. A network call usually retrieves data asynchronously. In your opinion how would Kotlin be given the data that was retrieved by Swift ?
I have no experience with JNI yet and I cannot figure out how to have a result asynchronously between Kotlin and Swift. For example if testNetworking() would retrieve a String.
How would Kotlin communicate with this function via JNI ?
public func testNetworking(completion: (String) -> Void) {
}
from swift-everywhere-toolchain.
It is theoretically doable, but making such bridge via JNI will be nightmare. I was thinking to update example without using JNI at all and using FFI instead.
Some info:
- https://github.com/jnr/jnr-ffi
- https://stackoverflow.com/questions/36819679/node-fficall-c-lib-with-callback-function
- https://github.com/ffi/ffi/wiki/Callbacks (Ruby example)
Initial idea to provide "more-less real-world example" obviously not reached when using JNI. Seems FFI+"Protocol buffers" is a way to go.
from swift-everywhere-toolchain.
Related Issues (20)
- Update to use last LTS release of NDK r21e - 21.4.7075529 HOT 1
- build toolchain for linux host machines HOT 4
- Update to use Swift v5.4.1 HOT 1
- host MacOS failed build for android NDK arm-linux-androideabi-gcc on $PATH at (eval 10) line 124. HOT 3
- SIGSEGV when calling print() HOT 5
- `null pointer dereference` crash on armeabi-v7a HOT 4
- Update to Swift release 5.4.2 HOT 1
- error: no such module 'Darwin.C' @_exported import Darwin.C while compile HOT 2
- swift package build fail HOT 15
- Update to use Swift 5.4.3 HOT 1
- Update to use Swift 5.5 HOT 12
- Question about build process HOT 6
- Where is concurrency lib? HOT 57
- Notarize toolchain.
- Toolchain for Apple Silicon HOT 2
- Does the build work right now? HOT 2
- CMath build errors HOT 1
- build error when xcode 13.3 command line tools are installed
- m1 apple silicon builds
- __aarch64_ldadd1_relax
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-everywhere-toolchain.