https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

Kurt Renzo Acosta

11/11/2019, 9:56 AM
Hi, guys! How do you declare flavors for Kotlin/Native? In Android I have two release types (Debug and Release) and two flavors (Dev and Production) so I have: - devDebug - devRelease - productionDebug - productionRelease I wanted to have these in iOS too but I can't seem to find any configuration so I only have Debug and Release for it. If I'm missing something, please do point me in the right direction. Many thanks!
a

Artyom Degtyarev [JB]

11/11/2019, 11:19 AM
Please share some details on your use-case. What for do you want to use these configurations? There was a conversation on this here(https://kotlinlang.slack.com/archives/C3PQML5NU/p1569574970173000?thread_ts=1569503173.151400&cid=C3PQML5NU), but I’m not sure is this relevant for you.
k

Kurt Renzo Acosta

11/11/2019, 2:21 PM
Thanks for the thread. I'll take a look at it tomorrow. Basically, we have two environments, one for us and one for end-users and with Android, we switch out URLs, API secrets, etc using flavors and BuildConfigs. Flavors still work on Android using multiplatform but we can't seem to find anything on how to make flavors for iOS (Kotlin/Native target)
a

alexfacciorusso

11/11/2019, 4:15 PM
Flavours are a feature exclusive to the Android Gradle plugin. What you can do for iOS is to create an entry point in your core module, where you can pass the name/id of the configuration. Then, based on that name/id you can select which configuration you want to sent to the app. I bet in iOS you can send this to gradlew using an environment variable set via different target types in the Xcode project
y

yshrsmz

11/12/2019, 4:41 AM
If what you need is to change constant variables, BuildKonfig is here for you https://github.com/yshrsmz/BuildKonfig
k

Kurt Renzo Acosta

11/12/2019, 4:42 AM
And that's actually what I just finished doing right now. Thank you for the library!
👍 1
40 Views