Open padmalcom opened 8 hours ago
why targetConfigs is nested inside a defaultConfigs?
My bad, I updated the config. Doing so, I had to change the android
funtion in targetConfigs
to create("android")
. Otherwise buildConfigFields
is unknown. And still the ios
function is unknown in the targetConfigs
context.
defaultConfigs("dev") {
buildConfigField(FieldSpec.Type.BOOLEAN, "DEBUG", "true")
buildConfigField(FieldSpec.Type.STRING, "API_VERSION", "v1/")
}
defaultConfigs("prod") {
buildConfigField(FieldSpec.Type.BOOLEAN, "DEBUG", "false")
...
}
targetConfigs("dev") {
create("android") {
buildConfigField(FieldSpec.Type.STRING, "BASE_URL", "http://10.0.2.2:8080/api/")
}
create("iosX64") {
buildConfigField(FieldSpec.Type.STRING, "BASE_URL", "http://localhost:8080/api/")
}
}
@padmalcom
Did you have applyDefaultHierarchyTemplate()
call in your kotlin configuration block?
https://github.com/yshrsmz/BuildKonfig/blob/master/sample-kts/build.gradle.kts#L21
And if that doesn't solve the problem, could you share that kotlin block?
No I haven't had the call in the kotlin block. I added it, synced and added ios and android functions again. But the issue remains the same.
Here is the entire kotlin block:
kotlin {
androidTarget("android") {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.addAll("-P", "plugin:org.jetbrains.kotlin.parcelize:additionalAnnotation=de.stonedrum.codaco.core.parcelize.MyParcelize")
}
}
// applyDefaultHierarchyTemplate()
listOf(
iosX64("iosX64"),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}
jvm("desktop")
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
applyDefaultHierarchyTemplate()
sourceSets {
val desktopMain by getting
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.material)
...
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
...
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.kotlinx.coroutines.swing)
...
}
iosMain.dependencies {
...
}
}
}
Thanks
You should add targetConfigs for ios
, not iosX64
.
As stated in the readme, you can either add BuildKonfig for ios or iosX64.
After changing create("iosX64") {
to create("ios") {
and rebuild the project, check your build directory. There should be buildkonfig
directory, and I'd like to see what's inside.
(Or if you can, simple repro is the most appreciated)
Describe the bug I am defining my targetConfigs in my flavoured defaultConfigs. The android target is found, the ios isn't showing an unresolved reference.
To Reproduce
Expected behavior I'd expect the target config ios to be found.
Desktop (please complete the following information):