I am working on a KMM project and I need to create different Schema for my project eg (Dev, Production, QA) I can easily do it in android part but I am not able to create the same in iOS. I tried creating different schemas normally we do in iOS app but my app crashes with the error targeting to our packForXcode
task in android studio.
Error while crash :- No enum constant org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEVELOPMENT
Here I have created a custom schema named development
This error points to
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
Now into binaries
I can see that there are two NativeBuildTargets
DEBUG
and RELEASE
so I can run in both of these but how can I create a custom schema for my iOS app ?
2
Answers
The problem is caused by the
mode
variable containing"configuration"
value, which is not an appropriate build type from the Kotlin/Native compiler point of view(see some details in the documentation). To avoid it, one should redefine the function determiningmode
s value. For example, it might be something like that:Below worked for me