Hello :wave: I have a kmp project that is sharing ...
# multiplatform
f
Hello đź‘‹ I have a kmp project that is sharing code between an iosapp and android app. I want to have some kind of segregation of the code in kmp and in the apps (android and ios), so that for example for QA builds can I have some experimental code but for production that code wouldn't be included. Any suggestion or approach that my work? Thanks
f
• The easy way by using feature flag and isolating your source code; • The hard way dynamically implement Kotlin modules during the build. ◦ In my project, I’m using environment variables to choose which module I need to implement
Not really a Kotlin multiplatform issue but more a Kotlin modules configuration. I guess you will find better example on the web.
f
Your second approach is the one I'm most interested in. The option with the feature flag I've tried but the experimental is still shipped inside the apps even though it is not called. Do you have any reference examples for the second approach? Thanks
f
I’m using this approach in production to separate Production/Non-Production secrets; You just need to inject something to your build task for specify which implementation you expect. For my project; I’m using environment variables.
> Do you have any reference examples for the second approach? I don’t have an example to give you, you just need to know you can dynamically select which “implementation” during the build.
Copy code
dependencies {
if (System.getEnv("PROD")) {
implementation("production.module")
} else {
implementation("non.production.module")
}
}
f
thanks for the inputs 🙏