KColor: A library to share color between Android and iOS in KMM
This article is about how to use KColor, a kotlin multiplatform library aimed to share color between android and ios.
GitRepo: https://github.com/mohitsoni48/KColor
How to install
Add ksp to project
google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp"}
In project level build.gradle
plugins {
//other plugins
alias(libs.plugins.google.devtools.ksp).apply(false)
}
In shared module build.gradle
plugins {
//other plugins
alias(libs.plugins.google.devtools.ksp)
}
kotlin {
sourceSets.commonMain {
kotlin.srcDir("build/generated/colors")
}
sourceSets {
commonMain.dependencies {
//...
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
if (name != "kspCommonMainKotlinMetadata" ) {
dependsOn("kspCommonMainKotlinMetadata")
}
}
ksp {
arg("packageName", "<YOUR_PACKAGE_NAME>")
arg("sharedModuleName", "<YOUR_SHARED_MODULE NAME>") //optional, default is shared
arg("iosAppName", "<YOUR IOS APP NAME>") //optional, default is iosApp
}
dependencies {
add("kspCommonMainMetadata"…