hey I see in gradle file I have kotlin block insid...
# multiplatform
v
hey I see in gradle file I have kotlin block inside that I have
getting/creating
. I know this property using delagate property. Can someone explain me what is use of
creating
and
getting
and when to use them. I am totally confused.
Copy code
val androidMain by getting {
            dependencies {
                implementation("androidx.core:core-ktx:1.3.2")
            }
        }

val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }

  val iosMain by creating { dependsOn(commonMain) }
        val iosX64Main by getting { dependsOn(iosMain) }
        val iosArm64Main by getting { dependsOn(iosMain) }
p
It is a property delegate that uses the name of the variable to create / locate the source set
v
Can you tell me what is difference in these two
Copy code
val iosMain by creating { dependsOn(commonMain) }
vs
Copy code
val iosX64Main by getting { dependsOn(iosMain) }
?
iosMain
is using
creating
and
iosX64Main
is
getting
. It little bit confusion.
p
It's about connecting source sets
iosMain is created
Then it depends on all the other iosXYZMains that already exist. Therefore the use the getting
v
Ok got it thanks