Kotlin multi-platform(KMPP) is Kotlin's experimental feature and 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.
4. 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
17. 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
19. Pros
Code sharing
Single source of truth for business logic to native platform
Less refactoring/rewriting e鍖orts
Time and cost saving
20. 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.