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

Kotlin Multiplatform

Avatar for Panini Panini
December 20, 2018

Kotlin Multiplatform

Avatar for Panini

Panini

December 20, 2018
Tweet

More Decks by Panini

Other Decks in Technology

Transcript

  1. About Me • Matthew Vern / Panini • Twitter: @callipan

    Github: panpanini • Mercari, Inc • Android Engineer (US) • Kotlin可愛い
  2. Summary • I made a Kotlin Multiplatform project! • It

    has an Android and iOS app both backed by a common library
  3. Kotlin Multiplatform - requirements • Multiplatform code must be 100%

    pure Kotlin • Platform specific code must be referenced using `expect` and `actual`
  4. Kotlin Multiplatform - tutorial • https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html • Explains how to

    use `expect` and `actual` mechanism expect fun platformName(): String fun createApplicationScreenMessage() : String { return "Kotlin Rocks on ${platformName()}" }
  5. Kotlin Multiplatform - tutorial v2.0 • I want a realistic

    sample project, that reflects real world usage • It should perform network operations • UI should be managed by each platform, so only logic should be shared
  6. Lets build! • I wrote some details in this blog,

    please check it! • https://tech.mercari.com/entry/2018/12/18/114010 • I want to build this architecture
  7. Lets build! • First, lets build http client • Because

    I’m normally an Android Engineer, lets use Retrofit • https://square.github.io/retrofit/ • It lets us make network calls just by creating an interface
  8. Kotlin Multiplatform - requirements • Multiplatform code must be 100%

    pure Kotlin • Platform specific code must be referenced using `expect` and `actual`
  9. Summary • I made a Kotlin Multiplatform project! • It

    has an Android and iOS app both backed by a common library • Http client is not as easy to use as Retrofit • return KotlinUnit() is ダサイ... • Kotlin works anywhere and that makes it 可愛い • https://github.com/panpanini/SplatMaps-Multiplatform