Thread
#multiplatform
    Jurriaan Mous

    Jurriaan Mous

    5 months ago
    I have an issue with the hierarchical project structure together with cinterop. I have switched to use a
    darwinMain
    shared sourceSet and platform specific cinterop implementations. It all works well to run
    macosArm64Test
    tasks and succeeds with all building and tests. But as soon I want to publish my library it wants to run
    compileDarwinMainKotlinMetadata
    it fails with the following exception failing to find cinterop based code which is only present in specific implementations:
    > 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:https://github.com/marykdb/rocksdb-multiplatform/blob/master/build.gradle.kts 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?
    m

    mkrussel

    5 months ago
    I ran into this issue as soon as I applied the
    maven-publish
    plugin. https://youtrack.jetbrains.com/issue/KT-42387 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.
    a

    Anton Lakotka [JB]

    5 months ago
    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

    Jurriaan Mous

    4 months ago
    @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)