BuildConfig migration
You can replace Android-only BuildConfig one constant at a time. Start with
values already read by shared code.
Migration steps
Section titled “Migration steps”- Inventory the constants that shared code actually reads
- Move shared values into
default.jsonordefault.yml - Move flavor-specific values into
flavors - Declare matching schema entries in
kayan { schema { ... } } - Keep the existing constant names for the first migration pass
- Swap imports from
BuildConfigto the generated Kayan object - Move Gradle-time decisions to
buildValue()only when the build script itself needs the resolved value
Before and after
Section titled “Before and after”// Beforeval baseUrl = BuildConfig.API_BASE_URL
// Afterimport sample.generated.SampleConfig
val baseUrl = SampleConfig.API_BASE_URLThe generated object lives in shared code. Every platform target can read it
without extra expect and actual declarations.
If different KMP targets need different values behind the same shared API, use
Target-specific generation. If the old
BuildConfig value drove dependencies, packaging metadata, or source-set wiring,
use Build-time config access.
