Hi everyone I am trying to implement build flavor...
# multiplatform
r
Hi everyone I am trying to implement build flavors using BuildKonfig for KMP. In general this works fine. I have configured an iosApp with multiple Targets. I made build schemes to build dev, stage and prod, where I changed the build kotlin framework script slightly to pass the target to gradle. This works fine, as long as I start the build and run task from Xcode, but when starting the task from within Android Studio, the ENV variables aren`t present for gradle, also even if I add them inside the build config itself in Android Studio. Is there something I am doing wrong or is this a bug?
m
I'm not sure what you're actually doing, but I'm using BuildKonfig by setting a variable in the project gradle.properties file
buildFlavour=<whatever>
and then in the build,gradle.kts of my common module I can access it with
val buildFlavour: String by project
2
r
@MarkRS BuildKonfig itself works just fine. I don’t have a variable buildFlavor in my properties, but I added Flafors for Android via
productFlavors {}
. With a small script on build time I read the flavor. This works also just fine. On the iOS side I added additional targets in xcode and changed the script for the Compile Kotlin Framework. For each Target there is a run configuration, that is present in Xcode and in Android Studio. When running one of these configurations from Xcode, gradle gets all the infos it needs to build the right flavor. But if I run one of these configs from Android Studio, it builds the default configuration and doesn’t gets the right flavor, but the iOS App itself gets built with the right flavor. Somehow the additional Info doesn’t get set for the gradle build. I also tried to add an ENV variable in the task directly and read this, but also ENV variables from the task aren’t passed to gradle build.