Good morning / afternoon... I have a small questi...
# multiplatform
c
Good morning / afternoon... I have a small question regarding the build.gradle.kts file of our shared module. Can someone provide an example of how defining build variants of the shared KMM module would look these days? My intention is to define custom configuration fields.
In a previous Android platform only project, I would define the flavors in this manner:
Copy code
productFlavors {
            create("simpsons") {
                dimension = "version"
                isDefault true
                buildConfigField "String", "KEYWORDS", "\" simpsons characters\""
                applicationId "com.example.simpsonsviewer"
                resValue "string", "app_name", "Simpsons Character Viewer"
            }
            create("wire") {
                dimension = "version"
                isDefault true
                buildConfigField "String", "KEYWORDS", "\"the wire characters\""
                applicationId "com.example.wireviewer"
                resValue "string", "app_name", "Wire Character Viewer"
            }
        }
But I see that copying+pasting this code into my KMM project produces compile errors. Something doesn't feel right
j
Hi, Coach! KMP doesn't have a build variant feature yet. Depending on your requirements, you might be able to do something similar using this plugin. Or you could also consider creating separate modules that define the flavor-specific code.
c
I guess the other option would be to create those variants in the Android App / iOS modules, and inject those custom fields of interest into the shared component. It's great to virtually see you on here, btw! You're too active on here 😄
I guess I'll use BuildConfig.
Jetbrains should consider acquiring that tool
j
create those variants in the Android App / iOS modules, and inject those custom fields
That's another good option, and actually what I've done myself, just differentiating between debug/release builds.