Home > Mobile >  Kotlin Multiplatform Mobile library structure
Kotlin Multiplatform Mobile library structure

Time:02-22

Some time ago I've created a KMM library from IntelliJ IDEA, using the "Mobile Application" project template. The structure was (with one root build.gradle.kts file):

libraryProject
- build.gradle.kts
- src
  - androidMain
  - commonMain
  - iosMain

Now, that template is missing from the list. There is just a "Library", which creates a jvm/js/common/native structure.

In Android Studio, the KMM plugin generates (for KMM library template):

libraryProject
- build.gradle.kts
- settings.gradle.kts
- libraryShared (this can be renamed)
  - build.gradle.kts
  - src
    - androidMain
    - commonMain
    - iosMain

This is just a KMM application without the actual iOS and Android platform modules. And, it comes with two build.gradle.kts files (root and shared).

I'm just curious if I missed anything or do I have to configure it manually, somehow.

All IDEs and plugins are up-to-date.

CodePudding user response:

When creating new project in Android Studio, one should be able to choose between two KMM projects(KMM Plugin is required to be installed):

  • KMM Library which contains only the shared module defined, and is intended to be used when one wants to add this library into existing iOS and Android apps.
  • KMM Application which creates a complete project with shared multiplatforn library, iOS app with ready integration, and the Android app.

Probably, in this case these two were confused. If you had only one option in the Wizard, please let me know which IDE and Plugin versions were used.

Note: Mobile library and Mobile Application were removed from IDEA by design,please see https://youtrack.jetbrains.com/issue/KTIJ-19232.

  • Related