[ad_1]
One of the best guide to show you find out how to share code throughout platforms utilizing Kotlin Multiplatform. You’ll achieve the inspiration of making consumer interfaces utilizing native UI toolkits after which writing frequent code for serialization, networking and persistence. You’ll additionally learn the way dependency injection, testing and completely different architectures slot in with Kotlin Multiplatform so that you just construct maintainable and scalable apps for the true world.
Earlier than You Start
This part tells you just a few issues it’s essential know earlier than you get began, equivalent to what you’ll want for {hardware} and software program, the place to search out the venture information for this guide, and extra.
Part I: Starting Kotlin Multiplatform
One of many core advantages of Kotlin Multiplatform is which you could share code throughout native apps. You’ll be able to proceed to develop the UI layer utilizing native UI toolkits like Jetpack Compose for Android and SwiftUI for iOS.
On this part, you’ll discover ways to add a brand new Gradle module to put in writing your corporation logic solely as soon as. You’ll additionally discover ways to create the native UI for Android, iOS and desktop apps, all whereas sharing the frequent module.
Kotlin Multiplatform (KMP) is likely one of the newest applied sciences that will help you share code throughout platforms. This chapter introduces you to KMP, how you should use it throughout app layers and find out how to arrange your first KMP venture.
1
Having dependable construct instruments and constant dependency variations is essential to getting began on a multiplatform venture. This chapter will cowl how you should use Gradle and its buildSrc module to supply dependencies to all modules. You will additionally discover ways to share enterprise logic throughout goal platforms utilizing a multiplatform time zone library.
2
Jetpack Compose is a brand new declarative library geared toward simplifying UI growth on Android. This chapter will stroll you thru creating a number of screens to your app utilizing Jetpack Compose.
3
SwiftUI is the fashionable method to program UI for iOS functions. On this chapter, you may discover ways to develop the UI for iOS utilizing the SwiftUI framework.
4
It is now doable to share the identical UI code throughout desktop and Android functions. On this chapter, you may discover ways to develop the UI for desktop utilizing the brand new Compose Multiplatform declarative library.
5
Part II: Kotlin Multiplatform: Intermediate
To successfully share code throughout apps, there are a number of issues to bear in mind: entry to platform-specific APIs, assist for current software program engineering practices and persistence.
On this part, you’ll discover ways to use Kotlin options to entry platform-specific APIs in your shared module and the way Kotlin Multiplatform suits in together with your present structure. You’ll additionally find out about dependency injection and the way you should use it to check options current in your shared modules. Lastly, you’ll discover ways to use a typical codebase to deal with persistence on completely different platforms.
When working with KMP, you may typically have to entry platform-specific APIs. On this chapter, you may take a deeper dive into the count on/precise sample and the way you should use them to entry platform-specific APIs.
6
Software program structure is likely one of the most important elements that have an effect on high quality and maintainability over time. On this chapter, you may get an summary of various architectures and the way you should use one in all them in your KMP software.
7
Writing assessments is a vital a part of writing code confidently. This chapter will present an summary of including unit assessments and UI assessments to an app created utilizing KMP.
8
Dependency Injection is a method that results in maintainable and testable code. This chapter will present an summary of integrating the Koin dependency injection library right into a multiplatform venture.
9
Most fashionable functions have to persist knowledge throughout classes. This chapter will present an summary of knowledge persistence in KMP. It discusses key-value saving in addition to utilizing an SQL database.
10
Part III: Kotlin Multiplatform: Superior
Networking is essential to most fashionable apps, and it normally includes implementing related logic utilizing completely different frameworks and languages. Underneath the hood, it additionally includes ideas like serialization and concurrency. Happily, Kotlin Multiplatform has devoted libraries for every of those.
On this part, you’ll discover ways to use serialization to decode JSON knowledge to Kotlin objects. You’ll then discover ways to use a typical networking library that leverages this frequent serialization to fetch knowledge from the web. To make the networking performant, you’ll additionally find out about concurrency in Kotlin utilizing coroutines and the issues for various platforms. Lastly, you’ll discover ways to extract an current function to a Kotlin Multiplatform library and in addition other ways of publishing this library.
When transmitting knowledge over a community, it’s essential serialize and deserialize it. On this chapter, you may discover ways to use serialization in a Kotlin Multiplatform venture.
11
Networking is likely one of the core options of any fashionable app. On this chapter, you may lean find out how to use networking in a Kotlin Multiplatform venture.
12
On this chapter, you may discover ways to use take care of concurrency in your Kotlin Multiplatform tasks.
13
On this chapter, you may study how one can migrate an current function to KMP. You additionally discover ways to publish a shared library and make it accessible for Android, iOS and desktop.
14
Part IV: Appendices
On this chapter, you may find out about a number of functionalities of Kotlin and their comparability with Swift.
A
Xcode does not assist debugging Kotlin Native code out of the field. On this chapter, you may study how one can debug your shared code module from Xcode.
B
On this chapter, you may study how one can share your Compose UI between Android and desktop apps.
C
[ad_2]