際際滷

際際滷Share a Scribd company logo
Lunch and Learn
Kotlin Multi-platform
on
Topics
 Presentation on Kotlin multi-platform

 Code overview

 Build framework and run a PoC app

 Q&A
Vikram Hooda

Mobile application developer
Kotlin Multi-platform
 Designed by JetBrains.

 Shares non-ui logic on di鍖erent platforms and uses
Kotlin language.

 Open source, natively-integrated and optional sharing.

 Code sharing, not cross-platform.

 Current Status: Experimental state
Target Platforms
Overview
Common
JSJVM Native
Java Android Browser Node
iOS Linux
Window Embedded
.jar .framework.js
Con鍖gure
KMPP project
Create a new Android and iOS project, if you do not
have one.
Create a new module(Shared) under Android project to
serve common functionality to target platforms.
Shared module
Now, create target speci鍖c directory under Shared
module.
Shared module directory structure
Set dependencies and target in Shared modules
build.gradle 鍖le.
Target con鍖guration
Target con鍖guration
Plugin con鍖guration
Plugin con鍖guration
Dependencies con鍖guration
Dependencies con鍖guration
Shared Logic
Mechanism
Common Module
(Shared business logic)
Native Platforms Module
(Android, iOS)
expect actual
expect/actual Keywords
 expect declares in common module.

 expect val plateformName: String //In common code

 actual de鍖nes in target module.

 actual val plateformName: String = Android //In Android code

 actual val plateformName: String = iOS //In iOS code
Example of expect/actual keyword
Pro & Cons
Pros
 Code sharing

 Single source of truth for business logic to native platform

 Less refactoring/rewriting e鍖orts

 Time and cost saving
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 platforms basic knowledge i.e.
Kotlin, Swift, Android and iOS apis.
Code
iOS: 
https://github.com/vkhooda24/KnowMyCountry-iOS-Multi-platform
Android and Multi-platform: 
https://github.com/vkhooda24/KnowMyCountry-Kotlin-Multiplatform
Thank you!

More Related Content

Kotlin multi platform