functionland / rs-wnfs-archived

Webnative FileSystem Core Components
Apache License 2.0
0 stars 0 forks source link

Create Java And Swift Libraries From Rust/WASM To Be Used In React-Native Project #1

Open ehsan6sha opened 1 year ago

ehsan6sha commented 1 year ago

Summary

We need the below wasm (rust) library to be integrated in a Java and in a Swift package so that we can use it in a react native application:

https://github.com/wnfs-wg/rs-wnfs

Problem

Running the webassembly version out of the box is not possible in Android using react-native

Describe the pain that this feature will solve

It enables wnfs to be used in Android applications that are made with react native

Impact

We cannot use wnfs in react native for android until this is resolved

Solution

using JNI is one solution: https://medium.com/@marekkotewicz/building-a-mobile-app-in-rust-and-react-native-part-2-hello-world-60970a7d194a

https://robertohuertas.com/2019/10/27/rust-for-android-ios-flutter/#:~:text=If+you+want+to+generate,on+it+and+select+Run+.

https://medium.com/@1ok1/android-rust-ndk-starter-dfb6f739ceed

https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html

And it also might need some work on iOS. WE need to be crate the JAVA and Swift libraries and import in react-native

Detail

Describe the solution you'd like After the implementation we should have JAVA and Swift libraries that are created from the rust code and we can use in react native to call methods without performance issues. It should have clear instructions on how to recreate it when a new update is issued.

Describe alternatives you've considered We considered using web assembly in a webview, but it has performance problems

exitflynn commented 1 year ago

Hello! :wave: I'd like to work on this!

ehsan6sha commented 1 year ago

@exitflynn hi, feel free to start working on it and will coordinate for the bounty upon delivery. The first deliverable is an Android app that has imported a library you created and is able to call WNFS methods in the readme. 2nd deliverable is the ios one.

ruseinov commented 1 year ago

@ehsan6sha FYI: For WebAssembly on Android something to look at: https://news.ycombinator.com/item?id=30302513 For native on Android/iOS + wasm web: https://www.artificialworlds.net/blog/2022/07/06/building-cross-platform-rust-for-web-android-and-ios-a-minimal-example/

The latter might be the best approach, needs to be tested though. By the looks of it it's best to compile Rust stuff to native libraries and then use the API through Android/iOS bindings.

Very happy to help with Rust interfaces should anything need to be modified.