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

Sam

03/06/2023, 6:17 PM
Hello, all! I've got a simple question that is proving surprisingly hard to google: What's the best way to check environment in a KMM project? That is, for the hypothetical code
if (isProduction) ...
, how would you define
isProduction
?
d

Derek Ellis

03/06/2023, 6:18 PM
You could use a plugin like BuildKonfig to generate constants, and you can set the value as part of your gradle build setup
s

Sam

03/06/2023, 6:27 PM
Ah, this looks like it could work, thanks!
a

Adam S

03/06/2023, 7:18 PM
It’s possible to generate a file with a Gradle task too: https://stackoverflow.com/a/74771876/4161471
8 Views