JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

How to use a third-party C++ library in a Compose Multiplatform project? #4962

Open ijero opened 1 week ago

ijero commented 1 week ago

I am an Android developer and I want to use a cross-platform library, https://github.com/bblanchon/pdfium-binaries, as a third-party dependency in my own project. I can use JNI to work with the Android .so files. However, I'm not sure how to import the .dylib files for the iOS platform or the *.wasm files for WebAssembly, where to place them in the project, and how to use them.

After generating a project template using https://kmp.jetbrains.com/, I'm not sure how to proceed. Are there any sample code examples that I can refer to?

Schahen commented 1 week ago

To my knowledge there's no sample project that demonstrates how it's done but actually Compose Multiplatform itself is relying on interopping with C++ in some aspects - take a look to https://github.com/JetBrains/skiko it's a good starting point to learn how this is done in a multiplatform project.