target ios does not contains correct values. (ComposeApp module hierarchy)
Moozart opened this issue · comments
create("ios") {
buildConfigField(FieldSpec.Type.STRING, "target", "ios")
}
But iosX64Main, isoArmX64Main and iosSimulatorArmX64 has "public actual val target: String = "common""
@Moozart
could you give me more info?
e.g) kotlin version, kmp plugin version, gradle version
@RyuNen344 Ofcourse,
kotlin = "1.9.23"
distributionUrl=https://services.gradle.org/distributions/gradle-8.2-bin.zip
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Thanks, I'll see later 😉
I have made investigation, and looks like issue fixes if we specify ios target like this:
targetConfigs {
create("android") {
buildConfigField(...)
}
create("iosArm64") {
buildConfigField(...)
}
create("iosSimulatorArm64") {
buildConfigField(...)
}
create("iosX64") {
buildConfigField(...)
}
}
@egorikftp Thanks for the research. I haven't tried it but if it works I will use it with this scoped func. Writing all ios modules one by one made me a bit lazy :)
fun NamedDomainObjectContainer<TargetConfigDsl>.crateForIOS() { listOf("iosArm64", "iosSimulatorArm64", "iosX64").forEach { create(it) { buildConfigField(FieldSpec.Type.STRING, "target", "ios") } } }
i can suggest more optimized dsl
fun NamedDomainObjectContainer<TargetConfigDsl>.ios(block: TargetConfigDsl.() -> Unit) {
listOf("iosArm64", "iosSimulatorArm64", "iosX64").forEach {
create(it, block)
}
}
fun NamedDomainObjectContainer<TargetConfigDsl>.android(block: TargetConfigDsl.() -> Unit) {
create("android", block)
}
fun TargetConfigDsl.buildConfigField(name: String, value: String) {
buildConfigField(type = STRING, name = name, value = value, const = true)
}
Usage
buildkonfig {
defaultConfigs {
buildConfigField(name = "versionName", value = "0.0.0")
}
targetConfigs {
android {
buildConfigField(name = "versionName", value = "2.0.0")
}
ios {
buildConfigField(name = "versionName", value = "1.0.0")
}
}
}