rsetkus

    rsetkus

    1 year ago
    Hi. When new multiplatform project is created (Linux machine),
    iosMain
    platform target is set to Multiplatform (screenshot bellow). That causes issues on Mac machine.
    iosMain
    cannot access platform code and have to duplicate code in
    iosArm64Main
    and
    iosX64Main
    . What platform target should be selected for
    iosMain
    on which
    iosArm64
    and
    iosX64
    depends on? Also, noticed that on Android Studio, using new KMM plugin,
    iosMain
    platform is set to multiple values Native(ios_arm64), Native(ios_x64). Is it possible to achieve the same on Intellij (platform target is single selection field)?
    Big Chungus

    Big Chungus

    1 year ago
    Google and read about kotlin native commonizer introduced in kotlin 1.4
    It's what you need to solve your issue
    rsetkus

    rsetkus

    1 year ago
    Hi @Big Chungus. Kotlin Native commonizer is exactly what we're trying to achieve but it is not working for us. I suspect it is because of default Intellij module settings. It is inconsistent between Intellij and Android Studio (also Intellij IDE). I doubt that Native module should be set to Multiplatform option. Android Studio KMM plugin sets to Native(ios_arm64), Native(ios_x64) and commonizer works fine there.
    Big Chungus

    Big Chungus

    1 year ago
    What's your current sourceSet hierarchy?
    Also, changing stuff in IDEA module configs ir redundant as it'll be overriden next time you sync gradle
    Try creating a new "nativeMain" sourceSet in gradle. Have it depend on commonMain and then have iosMain and linuxMain depend on nativeMain
    Note that with this setup IDEA might show you errors, but gradle should still compile fine since commonizer is not yet perfect
    rsetkus

    rsetkus

    1 year ago
    Current source sets
    val commonMain by getting {
                dependencies {
                   ...
                }
            }
    
            val androidMain by getting {
                dependencies {
                    ...
                }
            }
    
            val iosMain by getting {
                dependencies {
                    ...
                }
            }
    
            val iosX64Main by getting {
                dependencies {
                    dependsOn(iosMain)
                }
            }
    
            val iosArm64Main by getting {
                dependencies {
                    dependsOn(iosMain)
                }
            }
    For those who have the same issue and were searching in this channel, my problem was caused by missed gradle properties which is essential when migrating to 1.4 compiler. To resolve commonizer issue, set these values in your gradle.properties
    kotlin.mpp.enableGranularSourceSetsMetadata=true
    kotlin.native.enableDependencyPropagation=false
    Big Chungus

    Big Chungus

    1 year ago
    Thought you had that already as this is the first thing they talk about in release notes 😀
    rsetkus

    rsetkus

    1 year ago
    We started when 1.3 was around and absolutely missed this tiny little thing 🙂 . There were many things introduced in 1.4, easy to miss. 🙂 Anyway, thanks for you help and effort.
    Big Chungus

    Big Chungus

    1 year ago
    I still have no idea what enableDependencyPropagation actually does and why it is needed