Hi guys, in a KMM mobile project, do we need to `d...
# multiplatform
b
Hi guys, in a KMM mobile project, do we need to
dependsOn(commonMain)
in the
iosMain
block ? something like
Copy code
val iosMain by getting {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
               dependencies {
               }
}
j
It depends. If you used
ios()
to create then no. If you created it yourself the traditional way then yes. If you created it yourself using the new target hierarchy DSL then no.
b
could you please elaborate more, what do you mean by using
ios() to create
j
Copy code
kotlin {
  ios()
}
It's a shortcut for defining a few (but not all) of the iOS targets and a shared source set.
b
this is currently what i have
Copy code
kotlin {
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    
    android {}

    cocoapods {}
    
    sourceSets {
        val commonMain by getting {}
        val androidMain by getting {}

        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by getting {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
            dependencies {
            }
        }
    }
}
j
nothing is creating the
iosMain
source set there. Change
getting
to
creating
.
b
I see, thank you so much
p
Please also have a look at this doc on how you can make that even more concise: https://kotlinlang.org/docs/multiplatform-hierarchy.html
🙌 3