# multiplatform

Jurriaan Mous

04/06/2022, 7:44 PM
I have an issue with the hierarchical project structure together with cinterop. I have switched to use a
shared sourceSet and platform specific cinterop implementations. It all works well to run
tasks and succeeds with all building and tests. But as soon I want to publish my library it wants to run
it fails with the following exception failing to find cinterop based code which is only present in specific implementations:
Copy code
> Task :compileDarwinMainKotlinMetadata FAILED
e: /Users/jurmous/space/rocksdb-multiplatform/src/appleMain/kotlin/maryk/rocksdb/AbstractComparator.kt: (5, 8): Unresolved reference: rocksdb
The build.gradle.kts setup I use: Project can be checked out and build but macOS is needed. What am I missing so publishing completes successfully? And is publishing the metadata of that shared darwinMain sourceSet needed?


04/06/2022, 7:49 PM
I ran into this issue as soon as I applied the
plugin. My workaround was to add a project level property that can be set on the command line to say that I'm going to publish. When the flag is set, I avoid any shared source sets and instead create each of the target platforms and add kotlin directory to their source sets for the common code. I also have to add all dependencies and configuration settings to each of the individual targets. I went with the flag, because without it Android Studio says there are multiple source roots for the directory and picks one of them to use. This causes a lot of false errors and warnings.
Not sure if you are encountering the same problem.

Anton Lakotka [JB]

04/07/2022, 7:24 AM
Hi Jurriaan, it looks like your build setup is complicated (it is not an excuse of not working tooling for cinterops though 🙂 ). But could you try to simplify your setup? And if you will ran out of clues you can report a new issue. We are working on better support of Cinterop commonization and your input would be valuable. upd: it seems like I can reproduce it by having just two macosX64 and macosArm64 targets. That have same cinterop configuration that points to the same headers / static library. And cinterop commonization results nothing. Which is wrong. Could you please create a YouTrack issue? We will investigate that

Jurriaan Mous

05/26/2022, 10:14 AM
@Anton Lakotka [JB] Thanks for looking into it! It took a bit more time for me to get back to it but I created an issue in Youtrack. I also simplified the gradle by inlining the functions and updating to Kotlin 1.7.0-RC (Which had the same issue)