Kotlin Multiplatform - requirements
● Multiplatform code must be 100% pure Kotlin
● Platform specific code must be referenced using `expect` and `actual`
Slide 8
Slide 8 text
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()}"
}
Slide 9
Slide 9 text
:thinking:
Slide 10
Slide 10 text
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
Slide 11
Slide 11 text
Lets build!
Slide 12
Slide 12 text
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
Slide 13
Slide 13 text
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
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
Kotlin Multiplatform - requirements
● Multiplatform code must be 100% pure Kotlin
● Platform specific code must be referenced using `expect` and `actual`
Ktor
● https://ktor.io
● Kotlin http server
● Kotlin http client
● Multiplatform support
Slide 21
Slide 21 text
Lets build!!!!
Slide 22
Slide 22 text
Service.kt
Slide 23
Slide 23 text
ViewModel.kt
Slide 24
Slide 24 text
Observable.kt
Slide 25
Slide 25 text
Lets build iOS!!!!
Slide 26
Slide 26 text
Observable.kt
Slide 27
Slide 27 text
Observable.kt
Slide 28
Slide 28 text
Lets open Xcode!!!!
Slide 29
Slide 29 text
Xcode………..
Slide 30
Slide 30 text
SplatMaps.xcproject
Slide 31
Slide 31 text
ViewController.swift
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
Lets build Android!!!!
Slide 34
Slide 34 text
SplatoonCoroutine.idea
Slide 35
Slide 35 text
MatchFragment.kt
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
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