Slide 1

Slide 1 text

@RussHWolf ( or ) What's New in Kotlin Multiplatform Droidcon Americas 2020 Russell Wolf

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Kotlin is a language for... • Android • JVM (Server, Desktop) • JS (Browser, Node) • Native (LLVM, C interop) • iOS (Objective-C Interop)

Slide 4

Slide 4 text

Kotlin Multiplatform • Common code compiles to multiple targets • Platform-specific code can interop with that platform • Flexible - share only what makes sense to your use-case

Slide 5

Slide 5 text

Kevin Galligan "Shared UI is a history of pain and failure. Shared logic is the history of computers."

Slide 6

Slide 6 text

Mobile is the killer app for Kotlin Multiplatform

Slide 7

Slide 7 text

https://kotlinlang.org/lp/mobile/

Slide 8

Slide 8 text

MPP KMP
 KMM

Slide 9

Slide 9 text

Shared Code

Slide 10

Slide 10 text

Shared Code Android Common iOS

Slide 11

Slide 11 text

Shared Code Android Common iOS

Slide 12

Slide 12 text

Shared Code Android Common iOS

Slide 13

Slide 13 text

Shared Code Android Common iOS

Slide 14

Slide 14 text

Shared Code Android Common iOS

Slide 15

Slide 15 text

Shared Code Android Common iOS

Slide 16

Slide 16 text

Shared Code Android Common iOS

Slide 17

Slide 17 text

Architecture

Slide 18

Slide 18 text

Common iOS Framework Android AAR Architecture

Slide 19

Slide 19 text

Common iOS Framework Android AAR Android App iOS App Architecture

Slide 20

Slide 20 text

... ... Common iOS Framework Android AAR Android App iOS App Architecture

Slide 21

Slide 21 text

Common iOS Framework Android AAR ... ... Android App iOS App ... Architecture

Slide 22

Slide 22 text

Multiplatform Code

Slide 23

Slide 23 text

Common Code // Common
 class Thing(val data: List) { fun doSomething() { data.forEach { println(it) } } }

Slide 24

Slide 24 text

Platform-Specific Code // Common
 expect val platform: String
 // Android
 actual val platform = "Android" 
 // iOS
 actual val platform = "iOS"

Slide 25

Slide 25 text

Platform-Specific Code // Common
 interface Logger { fun log(message: String) }
 // Android
 class AndroidLogger : Logger { ... }
 // iOS - Kotlin
 class IosLogger { ... }
 // iOS - Swift class SwiftLogger : Logger { ... } // Common
 class TestLogger : Logger

Slide 26

Slide 26 text

So What's New?

Slide 27

Slide 27 text

Docs!

Slide 28

Slide 28 text

https://kotlinlang.org/lp/mobile/

Slide 29

Slide 29 text

https://kotlinlang.org/docs/mobile

Slide 30

Slide 30 text

https://kotlinlang.org/docs/reference/mpp-intro.html

Slide 31

Slide 31 text

Tooling

Slide 32

Slide 32 text

KMM Android Studio Plugin

Slide 33

Slide 33 text

Xcode Kotlin Plugin https://github.com/touchlab/xcode-kotlin

Slide 34

Slide 34 text

IDEA Project Wizard

Slide 35

Slide 35 text

Heirarchical Project Structure and Gradle Metadata

Slide 36

Slide 36 text

Heirarchical Project Structure kotlin.mpp.enableGranularSourceSetsMetadata=true
 kotlin.native.enableDependencyPropagation=false

Slide 37

Slide 37 text

Threading

Slide 38

Slide 38 text

Kotlin/Native Threading

Slide 39

Slide 39 text

Libraries

Slide 40

Slide 40 text

kotlinx-coroutines https://github.com/Kotlin/kotlinx.coroutines • Suspend functions and Flows • Separate single-threaded and multithreaded versions • 1.3.9 vs 1.3.9-native-mt

Slide 41

Slide 41 text

ktor https://github.com/ktorio/ktor • Http client • Uses native-mt coroutines version

Slide 42

Slide 42 text

kotlinx-serialization https://github.com/Kotlin/kotlinx.serialization • Multi-format serialization • First stable release! • API changes • New docs

Slide 43

Slide 43 text

kotlinx-datetime https://github.com/Kotlin/kotlinx-datetime • New! • Small API surface • Report issues and use-cases

Slide 44

Slide 44 text

Jetpack Compose?

Slide 45

Slide 45 text

Community libs • SqlDelight • Multiplatform Settings • Stately • Koin, Kodein • More at: • https://github.com/AAkira/Kotlin-Multiplatform-Libraries • https://kotlinlang.org/lp/mobile/ecosystem/

Slide 46

Slide 46 text

Samples

Slide 47

Slide 47 text

KaMPKit https://github.com/touchlab/KaMPKit

Slide 48

Slide 48 text

https://github.com/joreilly/PeopleInSpace https://github.com/joreilly/BikeShare

Slide 49

Slide 49 text

https://github.com/russhwolf/multiplatform-hello

Slide 50

Slide 50 text

... and more

Slide 51

Slide 51 text

Resources • KMM Portal: https://kotlinlang.org/lp/mobile/ • KMM Docs: https://kotlinlang.org/docs/mobile/samples.html • Multiplatform Docs: https://kotlinlang.org/docs/reference/mpp-intro.html • Codelabs: https://play.kotlinlang.org/hands-on/overview • Roadmap: https://kotlinlang.org/roadmap.html • KaMPKit: https://github.com/touchlab/KaMPKit

Slide 52

Slide 52 text

@RussHWolf ( or ) Questions? Russell Wolf