Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin Multi-platform

Kotlin Multi-platform

Kotlin multi-platform(KMPP) is Kotlin's experimental feature and it provides the ability to share non-UI business logic between different platforms like Android, iOS, Js, Embedded device and many more.

This slide covers how to set-up the KMPP project, how does this code sharing works between different platforms and pro-cons of using it.

Avatar for VK Hooda

VK Hooda

April 08, 2020

Other Decks in Programming

Transcript

  1. Kotlin Multi-platform • Designed by JetBrains. • Shares non-ui logic

    on different platforms and uses Kotlin language. • Open source, natively-integrated and optional sharing. • Code sharing, not cross-platform. • Current Status: Experimental state
  2. Common JS JVM Native Java Android Browser Node iOS Linux

    Window Embedded .jar .framework .js
  3. Create a new module(“Shared”) under Android project to serve common

    functionality to target platforms. Shared module
  4. • “expect” declares in common module. • expect val plateformName:

    String //In common code • “actual” defines in target module. • actual val plateformName: String = “Android” //In Android code • actual val plateformName: String = “iOS” //In iOS code
 Example of “expect/actual” keyword
  5. Pros • Code sharing • Single source of truth for

    business logic to native platform • Less refactoring/rewriting efforts • Time and cost saving
  6. Cons • Lack of libraries support . • Concurrency complications

    on iOS. • Painful debugging and runtime exception tracing on yet supported on iOS . • Must to have all targeted platform’s basic knowledge i.e. Kotlin, Swift, Android and iOS apis.