A template for creating Kotlin Multiplatform libraries with full platform support and Compose Multiplatform sample app.
| Platform | Targets | Status |
|---|---|---|
| Android | android | Supported |
| iOS | iosX64, iosArm64, iosSimulatorArm64 | Supported |
| macOS | macosX64, macosArm64 | Supported |
| tvOS | tvosX64, tvosArm64, tvosSimulatorArm64 | Supported |
| watchOS | watchosX64, watchosArm32, watchosArm64, watchosSimulatorArm64, watchosDeviceArm64 | Supported |
| JVM | jvm | Supported |
| Linux | linuxX64, linuxArm64 | Supported |
| Windows | mingwX64 | Supported |
| JavaScript | js (Browser, Node.js) | Supported |
| WebAssembly | wasmJs (Browser, Node.js), wasmWasi (Node.js) | Supported |
Add the dependency to your build.gradle.kts:
// In your shared module
kotlin {
sourceSets {
commonMain.dependencies {
implementation("TEMPLATE_PACKAGE:template-library:1.0.0")
}
}
}Android
No additional setup required.
iOS
No additional setup required.
import TEMPLATE_PACKAGE.Greeting
fun main() {
val greeting = Greeting()
println(greeting.greet()) // Hello from [Platform]!
println(greeting.greet("World")) // Hello, World! Welcome from [Platform].
}For detailed documentation, visit [Documentation Link].
- JDK 17 or higher
- Android SDK (for Android development)
- Xcode 15+ (for iOS development, macOS only)
- Clone the repository:
git clone https://github.com/TEMPLATE_ORG/TEMPLATE_REPO.git
cd TEMPLATE_REPO- Customize the template (first time only):
bash customizer.sh com.yourpackage.library YourLibraryName your-org- Set up git hooks:
bash scripts/setup-hooks.sh- Build the project:
./gradlew build# All platforms
./gradlew allTests
# Specific platforms
./gradlew jvmTest
./gradlew iosSimulatorArm64Test
./gradlew testAndroidHostTest
./gradlew linuxX64Test# Format code
./gradlew spotlessApply
# Run static analysis
./gradlew detektA Compose Multiplatform sample app is included to test the library on all platforms:
# Run on Desktop (macOS, Windows, Linux)
./gradlew :sample-app:run
# Run on Android
./gradlew :sample-app:installDebug
# Run on iOS (requires Xcode on macOS)
# Open sample-app in Xcode or use KMM plugin in Android Studio
# Run on Web (WebAssembly)
./gradlew :sample-app:wasmJsBrowserRun- Create a Sonatype account
- Generate a GPG key for signing
- Configure GitHub secrets:
MAVEN_CENTRAL_USERNAME- Sonatype usernameMAVEN_CENTRAL_PASSWORD- Sonatype passwordSIGNING_KEY_ID- GPG key IDSIGNING_PASSWORD- GPG key passwordGPG_KEY_CONTENTS- Base64 encoded GPG private key
- Update version in
cmp-library/build.gradle.kts - Create a GitHub release with a tag (e.g.,
v1.0.0) - The publish workflow will automatically deploy to Maven Central
.
├── cmp-library/ # Library module
│ └── src/
│ ├── commonMain/ # Common code (all platforms)
│ ├── commonTest/ # Common tests
│ ├── androidMain/ # Android-specific code
│ ├── jvmMain/ # JVM-specific code
│ ├── appleMain/ # Apple platforms (iOS, macOS, tvOS, watchOS)
│ ├── linuxMain/ # Linux platforms (linuxX64, linuxArm64)
│ ├── mingwMain/ # Windows (mingwX64)
│ ├── jsMain/ # JavaScript (Browser, Node.js)
│ ├── wasmJsMain/ # WebAssembly JS
│ └── wasmWasiMain/ # WebAssembly WASI
├── sample-app/ # Compose Multiplatform sample app
│ └── src/
│ ├── commonMain/ # Shared UI code
│ ├── androidMain/ # Android app entry
│ ├── desktopMain/ # Desktop app entry
│ ├── iosMain/ # iOS app entry
│ └── wasmJsMain/ # Web app entry
├── scripts/ # Automation scripts
│ ├── pre-commit.sh # Pre-commit hook
│ ├── pre-push.sh # Pre-push hook
│ └── setup-hooks.sh # Hook setup script
├── config/
│ └── detekt/ # Detekt configuration
├── .github/
│ ├── workflows/ # GitHub Actions
│ └── ISSUE_TEMPLATE/ # Issue templates
├── customizer.sh # Template customization script
└── build.gradle.kts # Root build configuration
We welcome contributions! Please see our Contributing Guide for details.
Copyright 2025 MobileByteLabs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.