Skip to content

vitoksmile/HelloComposeMPP

Repository files navigation

Compose Multiplatform mobile application

Platforms:

  • Android
  • iOS
  • Desktop (Windows, macOS, Linux)

Set up the environment

Warning You need a Mac with macOS to write and run iOS-specific code on simulated or real devices. This is an Apple requirement.

To work with this template, you need the following:

Check your environment

Before you start, use the KDoctor tool to ensure that your development environment is configured correctly:

  1. Install KDoctor with Homebrew:

    brew install kdoctor
    
  2. Run KDoctor in your terminal:

    kdoctor
    

    If everything is set up correctly, you'll see valid output:

    Environment diagnose (to see all details, use -v option):
    [✓] Operation System
    [✓] Java
    [✓] Android Studio
    [✓] Xcode
    [✓] Cocoapods
    
    Conclusion:
      ✓ Your system is ready for Kotlin Multiplatform Mobile development!
    

Otherwise, KDoctor will highlight which parts of your setup still need to be configured and will suggest a way to fix them.

Examine the project structure

Compose Multiplatform project includes 4 modules:

shared

This is a Kotlin module that contains the logic common for Android, iOS and Desktop applications, that is, the code you share between platforms.

androidApp

This is a Kotlin module that builds into an Android application. It uses Gradle as the build system. The androidApp module depends on and uses the shared module as a regular Android library.

iosApp

This is an Xcode project that builds into an iOS application. It depends on and uses the shared module as a CocoaPods dependency.

desktopApp

This is a Desktop project that builds into a Desktop application. The desktopApp module depends on and uses the shared module as a regular jvm library.

Run application

On Desktop

Run Gradle tasks :

  • ./gradlew :desktopApp:run to run the application
  • ./gradlew :desktopApp:createDistributable to store native distribution into build/compose/binaries/main/app