Is there any way to know, when building shared KMP...
# multiplatform
j
Is there any way to know, when building shared KMP code as part of iOS build, which build configuration is being used?
I looked in
Platform
for example and don't see anything like that (other than say
isDebugBinary
)
p
Can pass in properties into the gradle build command which can then be accessed in the same way as anything in the
gradle.properties
file would be on the KMP side. We've got this when building the shared framework with
KMP_ENVIRONMENT
being defined per configuration as a user defined build setting in Xcode.
Copy code
./gradlew :shared:embedAndSignAppleFrameworkForXcode -Pbuildkonfig.flavor=$KMP_ENVIRONMENT
For use with this library - https://github.com/yshrsmz/BuildKonfig
👍 1
j
Thanks @Patrick Cavanagh, that makes sense
🫡 1
Looks like I can use
$CONFIGURATION
directly. Though maybe approach of having something like
KMP_ENVIRONMENT
might be more flexible....are you defining that then in different
.xcconfig
files?
p
Yep, exactly that - separate
.xcconfig
files per server environment with a variety of things defined.
Most of them we're just populating into the
info.plist
then accessing at runtime but that one is passed in to help generate the BuildKonfig which has all of the shared config.
👍 1