KMPify is a Kotlin tool that helps migrate Android Jetpack Compose projects to Kotlin Multiplatform (KMP) with minimal effort. Available as both a CLI tool and Desktop GUI.
Migrating to Kotlin Multiplatform allows you to share code across multiple platforms. KMPify automates the repetitive tasks, It automatically scans .kt
files and applies a series of smart transformations to:
- Replace Android-specific resource imports with their KMP-compatible counterparts
- Convert
R.drawable
,R.string
, andR.font
references toRes.drawable
,Res.string
, etc. - Rebuild imports cleanly and inject resource references where needed
- Replace annotations like
@DrawableRes
and@StringRes
with their KMP alternatives - Replace previews, viewModels, and other common Compose elements
for more about migration steps see MigrationSteps
Before (Android):
import com.example.android.R
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@Composable
fun MainScreen() {
Image(painter = painterResource(id = R.drawable.icon), contentDescription = null)
Text(stringResource(id = R.string.app_name))
}
After (KMP):
import my_kmp_project.composeapp.generated.resources.Res
import my_kmp_project.composeapp.generated.resources.icon
import my_kmp_project.composeapp.generated.resources.app_name
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
@Composable
fun MainScreen() {
Image(painter = painterResource(resource = Res.drawable.icon), contentDescription = null)
Text(stringResource(resource = Res.string.app_name))
}
- Dual Interface: Use the CLI for quick, scriptable migrations or the Compose Desktop UI for an interactive experience.
- Flexible Processing: Supports single
.kt
files or entire directories with recursive processing. - Dry Run Mode: Preview changes without modifying files.
- User-Friendly UI: Simple desktop interface for inputting paths and configuration (optional).
- Reports: Generates a
MigrationSummary
andMigrationReport
detailing processed files and changes.
Usage: kmpify [<options>]
Options:
-i, --input=<path> The directory containing your Android .kt files, typically your main/java/ folder.
-o, --output=<path> The directory where the migrated files will be saved. Usually points to your KMP commonMain/kotlin/ directory.
-p, --project=<text> The name of your multiplatform project (used to build resource paths).
-s, --shared=<text> The name of your shared module. Defaults to 'composeapp' if left empty.
--preview=<text> If you're using a custom @Preview annotation, you can specify it here.
-d, --dry-run If true, KMPify will simulate the migration and show what would be changed, but won't overwrite any files.
-h, --help Show this message and exit
Download the latest release from the Releases page:
-
GUI Version (Desktop App):
- Download
KMPify-1.1.0.dmg
- Double-click to mount and drag KMPify to your Applications folder
- Download
-
CLI Version (Terminal):
- Download
kmpify-cli-macOs.zip
- Unzip the downloaded file
#Unzip unzip kmpify-cli-macOs.zip # Make executable chmod +x kmpify # Run ./kmpify --help
- Download
-
GUI Version (Desktop App):
# Clone the repository git clone https://github.com/MahmoudRH/kmpify.git cd kmpify # Run Desktop GUI ./gradlew :composeApp:run
-
CLI Version (Terminal):
- clone the repo
- go to the cli module and run
Main.kt
- Support for custom
@Preview
annotations. - Command-line interface as an alternative to the GUI.
- Hilt to Koin migration option
We welcome contributions to make KMPify better!
- Report bugs or request features at GitHub Issues.
- Open a PR with a clear description of changes and reference any related issues.
- Email: Reach out to [email protected].
- Follow: Stay updated on LinkedIn.
Star ⭐ this repository to support the project
KMPify is licensed under the Apache License 2.0. See the LICENSE file for details.