/mpp-example

Example of Kotlin multiplatform project

Primary LanguageKotlinApache License 2.0Apache-2.0

Multiplatform sample

This example shows you how to use Kotlin Multiplatform in an monorepo. The MPP code can be found inside the greeting/ directory while the "UI" implementations can be found inside the androidApp/ resp. iosApp/ dir.

This sample based on the multiplatform documentation. If you have questions about the structure or how it works take a look at the documentation there.

iOS

To compile the project from Xcode just open iosApp/iosApp.xcodeproj and run the application. The swift tests also can be executed from Xcode.

To compile a framework for ios simulator from the command line execute:

  > ./gradlew :greeting:build

To compile the framework for a device use the device project property:

  > ./gradlew :greeting:build -Pdevice=true

To run kotlin tests (including the common ones) on an iOS simulator execute:

  > ./gradlew :greeting:iosTest

By default the iPhone 8 simulator is used. One can change this setting using the iosDevice project property:

  > ./gradlew :greeting:iosTest -PiosDevice='iPhone 7'

Android

The application can be built and executed on a device or emulator using Android Studio 3.2 or higher. One can also compile the application and run tests from the command line:

   > ./gradlew :androidApp:build