Skip to content

santimattius/kmp-basic-template

Repository files navigation

KMP Basic Template

Kotlin Kotlin Multiplatform Android iOS Gradle Android SDK

Kotlin Multiplatform (KMP) project targeting Android and iOS, with a shared module and platform-specific app entry points.


1. Overview

This template provides a minimal structure for a Kotlin Multiplatform project:

  • Shared module — Common and platform-specific Kotlin code (Android, iOS).
  • Android app — Android application module (androidApp).
  • iOS app — iOS application project (iosApp).
Module Path Description
shared shared/ Shared KMP code. Main sources in shared/src/commonMain/kotlin. Platform code in androidMain, iosMain.
androidApp androidApp/ Android application. Entry point and Android-specific UI.
iosApp iosApp/ iOS application (Xcode project). Entry point and SwiftUI.

2. Prerequisites

  • JDK 17
  • Android Studio (Meerkat or later) or IntelliJ IDEA with Android and KMP support
  • Xcode (for iOS builds)
  • Gradle 9.4.0+ (wrapper included)

Optional: kdoctor to verify the KMP development environment.


3. Getting Started

3.1 Build and run

Android

./gradlew :androidApp:assembleDebug
# Or run the androidApp configuration from the IDE

iOS

Open iosApp/iosApp.xcodeproj in Xcode and run the app on a simulator or device.

Shared module (all targets)

./gradlew :shared:compileKotlinIosSimulatorArm64 :shared:compileAndroidMain

3.2 Run tests

./gradlew test

4. Configuration After Cloning

When creating a new project from this template, update the following.

4.1 Project name

File: settings.gradle.kts

Set the root project name:

rootProject.name = "YourNewProjectName"

4.2 Android application ID

File: androidApp/build.gradle.kts

Set the applicationId in the android { defaultConfig { ... } } block:

android {
    defaultConfig {
        applicationId = "com.yourcompany.yournewprojectname"
        // ...
    }
}

4.3 iOS bundle ID and display name

File: iosApp/Configuration/Config.xcconfig

Update at least:

Variable Description Example
APP_ID Bundle ID com.yourcompany.YourNewProjectName
APP_NAME Display name YourNewProjectName

5. Publishing the Shared Module

The shared module is set up for Maven publication via the gradle-maven-publish-plugin.

Action Command / Reference
Publish to local Maven ./gradlew :shared:publishToMavenLocal
Publish to Maven Central See docs/PUBLISHING.md for credentials and steps.

Default coordinates: com.santimattius.kmp:shared:1.0.0-SNAPSHOT
To change groupId, artifactId, or version, edit the mavenPublishing { coordinates(...) } block in shared/build.gradle.kts.


6. Environment Verification

It is recommended to run kdoctor to check that your environment is correctly configured for Kotlin Multiplatform. kdoctor reports and can help fix common setup issues.


7. References

Resource URL
Kotlin Multiplatform — Get started JetBrains Help
kdoctor GitHub
Maven publishing (this project) docs/PUBLISHING.md

About

Kotlin Multiplatform (KMP) project targeting Android and iOS, with a shared module and platform-specific app entry points.

Resources

Stars

Watchers

Forks

Contributors