Build config values depending on target with Kotlin Multiplatform
Build config values depending on target with Kotlin Multiplatform
Build config values depending on target with Kotlin Multiplatform
Tired of using expect/actual for managing build config values across multiple targets in Kotlin Multiplatform? Discover a streamlined solution to handle platform-specific configurations, making your setup cleaner and more maintainable!
Tired of using expect/actual for managing build config values across multiple targets in Kotlin Multiplatform? Discover a streamlined solution to handle platform-specific configurations, making your setup cleaner and more maintainable!
Tired of using expect/actual for managing build config values across multiple targets in Kotlin Multiplatform? Discover a streamlined solution to handle platform-specific configurations, making your setup cleaner and more maintainable!
Tired of using expect/actual for managing build config values across multiple targets in Kotlin Multiplatform? Discover a streamlined solution to handle platform-specific configurations, making your setup cleaner and more maintainable!
buildkonfig {
packageName = "com.smthg.app"
defaultConfigs {
// apiKey is overridden in targetConfigs.
buildConfigField(type = STRING, name = "THIRD_PARTY_API_KEY", value = "")
}
targetConfigs {
create("android") {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_android")
.orEmpty()
)
}
listOf(
"iosX64",
"iosArm64",
"iosSimulatorArm64",
).forEach { iosTarget ->
create(iosTarget) {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_ios")
.orEmpty
buildkonfig {
packageName = "com.smthg.app"
defaultConfigs {
// apiKey is overridden in targetConfigs.
buildConfigField(type = STRING, name = "THIRD_PARTY_API_KEY", value = "")
}
targetConfigs {
create("android") {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_android")
.orEmpty()
)
}
listOf(
"iosX64",
"iosArm64",
"iosSimulatorArm64",
).forEach { iosTarget ->
create(iosTarget) {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_ios")
.orEmpty
buildkonfig {
packageName = "com.smthg.app"
defaultConfigs {
// apiKey is overridden in targetConfigs.
buildConfigField(type = STRING, name = "THIRD_PARTY_API_KEY", value = "")
}
targetConfigs {
create("android") {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_android")
.orEmpty()
)
}
listOf(
"iosX64",
"iosArm64",
"iosSimulatorArm64",
).forEach { iosTarget ->
create(iosTarget) {
buildConfigField(
type = STRING,
name = "THIRD_PARTY_API_KEY",
value = project.rootProject
.getLocalProperty("third_party_api_key_ios")
.orEmpty
Start Earning Money on Stores by Shipping Your App At Lightning Speed
Start Earning Money on Stores by Shipping Your App At Lightning Speed
Free AppKickstarter version (save 1 day)
I'm passionate about making Kotlin and Compose Multiplatform resources widely accessible. That's why I've created a free template just for you. Claim yours now!
Get Free Template