

You can run your multiplatform application on Android or iOS. Real-life projects can have more complex structures. This is an example structure of a Multiplatform Mobile project that you create with the project wizard in IntelliJ IDEA or Android Studio. In Kotlin Multiplatform, different source sets in a shared module can target different platforms. Source set is a Gradle concept for a number of files logically grouped together where each group has its own dependencies. The shared module consists of three source sets: androidMain, commonMain, and iosMain. In this tutorial, it's a regular framework dependency. The shared module can be used as a regular framework or as a CocoaPods dependency, based on what you've chosen in the previous step in iOS framework distribution. It depends on and uses the shared module as an iOS framework. IosApp is an Xcode project that builds into an iOS application. The androidApp module depends on and uses the shared module as a regular Android library. The shared module builds into an Android library and an iOS framework.ĪndroidApp is a Kotlin module that builds into an Android application. It uses Gradle as the build system that helps you automate your build process. Shared is a Kotlin module that contains the logic common for both Android and iOS applications – the code you share between platforms. To view the full structure of your mobile multiplatform project, switch the view from Android to Project.Įach Kotlin Multiplatform project includes three modules: It may take some time to download and set up the required components when you do this for the first time. The project will be set up automatically. Keep the default names for the application and shared folders. To learn more about CocoaPods and how to set up an environment for them, see CocoaPods overview and setup. We recommend using the regular framework for your first project, as this option doesn't require third-party tools and has fewer installation issues.įor more complex projects, you might need the CocoaPods dependency manager that helps handle library dependencies. In the iOS framework distribution list, select the Regular framework option. Specify a name for your first application, and click Next.


Select Kotlin Multiplatform App in the list of project templates, and click Next. In Android Studio, select File | New | New Project. You can also watch the video version of this tutorial created by Ekaterina Petrova, Kotlin Product Marketing Manager. Here you will learn how to create and run your first Kotlin Multiplatform application using Android Studio.
