8000 Need full examples (2 as minimum) of integration Kotlin Multiplatform with Rust · Issue #24 · gobley/gobley · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Need full examples (2 as minimum) of integration Kotlin Multiplatform with Rust #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
paxbun opened this issue Mar 4, 2025 · 8 comments
Labels
examples & tests Related to examples and tests old Copied from the original GitLab repository

Comments

@paxbun
Copy link
Contributor
paxbun commented Mar 4, 2025

Original issue: https://gitlab.com/trixnity/uniffi-kotlin-multiplatform-bindings/-/issues/68

Hello! I need create bindings between kotlin multiplatform and rust. And I want use it, but I can't find full examples with uniffi, rust and kotlin multiplatform, and it is barrier for me to start using it. May who was using it. Thanks for your future help 🙏🏻
Maybe I have skipped examples, but I dont have been seeing minimal full examples, because documentation cant give enough understanding of how to work with it in real project.

I hope you will seen this and something will changed maybe. Your work on this plugins is awesome and I support you))

@paxbun paxbun added examples & tests Related to examples and tests old Copied from the original GitLab repository labels Mar 4, 2025
@miduch
Copy link
miduch commented Mar 4, 2025

thanks for awesome work. I created sample project using Kmp wizard and after following instructions in readme was able to get attached super simple example working on Android, iOS, JVM.

HelloKmpRust.zip

Everything went smooth, couple of small issues i faced were following (not mentioned in docs)

  1. before adding plugins to gradle make sure you have a rust project in dir otherwise gradle sync will fail
  2. kotlinAtomicfu plugin was needed as well, wasn't mentioned in docs. In addition i added kotlinSerialization as well

Wasm support seems to be missing. And i found this old issue. Issue is still open and is referring to old repo (maybe its worth mentioning in issue about new repo?)

It would be great to get Wasm working as well, it looks like there is some type of support for wasm already there mozilla/uniffi-rs#2417 if i'm not mistaken

Feel free to add this simple example to existing ones if you think its worth :)

@miduch
Copy link
miduch commented Mar 4, 2025

Wasm:

As of now nothing gets generated for wasm, and sample project wouldn't compile/run wasm target. Would it be possible to generate e.g. actual fun but throw unsupported exception or something so that atleast it compiles?

@paxbun
Copy link
Contributor Author
paxbun commented Mar 5, 2025

@miduch Thanks for the example! I'll check it when I get started working on making integration tests.

  1. Yeah, we need a library crate to successfully sync the project. That's probably because iOS cinterop runs at first during syncing, and we need to build the Rust library before cinterop runs.
  2. KotlinX AtomicFU is needed. The Atomic feature will be included in the standard library in Kotlin 2.1.20, so I'm waiting for it (well we still need to use KotlinX AtomicFU for lower versions). KotlinX Serialization is not mandatory. The UniFFI plugin will detect the presence of the KotlinX Serialization Gradle plugin and the KotlinX Serialization dependency and won't emit @Serialization if you don't use them. Please let me know if you still have a problem with @Serialization.

Yes, it seems UniFFI now supports wasm, but I haven't started working on it. If you need stub classes and functions for WASM, I'll try including them in 0.1.1 (or 0.2.0? thinking of it, the Gradle DSL has to be changed). The actual implementation needs more time.

@paxbun
Copy link
Contributor Author
paxbun commented Mar 5, 2025

@miduch I made a separate issue for WASM, so let's discuss it in #26.

@paxbun
Copy link
Contributor Author
paxbun commented Mar 5, 2025

The AtomicFU issue should be discussed here: #15

@paxbun
Copy link
Contributor Author
paxbun commented Mar 12, 2025

IMO, one example should use WGPU. WGPU interoperability shows two things:

  1. Gobley can be used to exchange complex data and platform-specific objects (Java objects on JVM platforms, NSObject* on Apple platforms)
  2. Rust can be a fair option to implement cross-platform CG logic on Kotlin Multiplatform.

To make a WGPU demo, we need Rust bindings to JAWT, which is in a private repo right now.

@miduch
Copy link
miduch commented Mar 12, 2025

CG logic on Kotlin Multiplatform

Do you mean GC?

When/If someday there is support for WASM, an example for that would be great too :)

@paxbun
Copy link
Contributor Author
paxbun commented Mar 12, 2025

@miduch No I mean Computer Graphics. WGPU is a cross platform graphics library. WASM support will definitely be added, as I need it. You can see my notes about how it will work under the hood in #9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples & tests Related to examples and tests old Copied from the original GitLab repository
Projects
None yet
Development

No branches or pull requests

2 participants
0