https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

rsetkus

11/01/2020, 7:39 PM
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)?
b

Big Chungus

11/01/2020, 10:29 PM
Google and read about kotlin native commonizer introduced in kotlin 1.4
It's what you need to solve your issue
r

rsetkus

11/02/2020, 9:34 AM
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.
b

Big Chungus

11/02/2020, 9:35 AM
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
r

rsetkus

11/02/2020, 9:51 AM
Current source sets
Copy code
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
👍 2
b

Big Chungus

11/04/2020, 3:54 PM
Thought you had that already as this is the first thing they talk about in release notes 😀
r

rsetkus

11/04/2020, 4:11 PM
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.
b

Big Chungus

11/04/2020, 5:21 PM
I still have no idea what enableDependencyPropagation actually does and why it is needed
2 Views