yshrsmz / BuildKonfig

BuildConfig for Kotlin Multiplatform Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ios configuration and environment variables

estivensh opened this issue · comments

for someone who has the doubt of how to call the variables generated from ios it would be as follows since I did not see practically no example that explained it:

in Kotlin

buildkonfig {
  packageName = "com.example.app"
  exposeObjectWithName = "BuildKonfigPublic"
}

in SwiftUI

import shared

BuildKonfigPublic().accessKey

for the second contribution I have about the environment variables because in some examples it is also confusing and the official documentation suggests to place it in the gradle.properties if you want to place it in the local.properties file from the shared module will not recognize the variable so I did the following:

import java.util.Properties

val localProperties = Properties()
localProperties.load(rootProject.file("local.properties").reader())

buildkonfig {  
   packageName = "com.example.app"
   exposeObjectWithName = "BuildKonfigPublic"
   defaultConfigs {
      buildConfigField(STRING, "accessKey", localProperties.getProperty("value"))
   }
}