KMP Compose Multiplatform App Project File Structure Guide

This tutorial teaches the essential file structure of a Kotlin Multiplatform Mobile App (KMM) project. We will understand the purpose of each directory and file and how they contribute to building cross-platform iOS and Android apps.

KMP Compose Multiplatform App Project File Structure Guide

KMP Compose Multiplatform App Project File Structure Guide

1. If you’re new to Kotlin Compose multiplatform, read our Project Create & setup guide before getting started.

2. After downloading and setting up the project, you will see a screenshot similar to the one below when you open your KMP project for the first time. Click on Android.

my first KMM project3. Select Project, This will open the KMP project as a separate project structure.

3. Now a different project structure will be opened.

4. The Project contains a specific folder composeApp. This is our main folder in which we would write all the Kotlin code. This folder has 3 different folders present inside.

  1. androidMain folder.
  2. commonMain folder.
  3. iosMain folder.

KMM compose multiplatfrom app

4. This is the androidMain directory that is used to write native Android Kotlin code. This folder contains the main folder, resource folder, and AndroidManifest.xml file.

Android Main KMM

5. The commonMain directory is used to write all the composed multiplatform Kotlin code for your KMM or KMP project.

common Main KMP folder

6. The iosMain folder is used to write iOS native code in Kotlin.

KMP iOS Main folder

7. You can find info.plist file which is required for iOS development in the iOSApp folder.

8. Your App-level build.gradle.kts file is present in commonMain folder.

App level build gradle file in KMP project

9. In your project root folder you can find your KMP project’s root build.gradle.kts file.

Root level build gradle in KMP app

10. The App.kt file is used to write and compose multiplatform code for our app for both Android & iOS platforms. This file is present in commonMain -> Kotlin -> Your Package Name.

App KT

I have tried my best to explain each folder’s usage in Kotlin KMP compose mthe ultiplatform project. If you need any help please feel free to comment and I will surely reply.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *