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
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.
3. 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.
- androidMain folder.
- commonMain folder.
- iosMain folder.
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.
5. The commonMain directory is used to write all the composed multiplatform Kotlin code for your KMM or KMP project.
6. The iosMain folder is used to write iOS native code in Kotlin.
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.
9. In your project root folder you can find your KMP project’s root build.gradle.kts file.
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.
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.