Kotlin Multiplatform is here! 🙌
I'm going to give a talk at Commit Porto about it:
👉 The Hitchhikers Guide Through Kotlin Multiplaform
This repository contains a demo of a simple application developed to show how we can have a shared logic module between two different targets - in this case, Android and iOS.
This is a two-screen application that allows to see all the speakers and talks that are going to happen at Commit Porto.
I've hosted a Gist here with a json that contains all the information about the speakers that will be talking at Commit Porto 19. The logic to download a file and parse it will be similar to both platforms - so why not adding this logic to a common module and leave all the UI implementation to the platforms themselves?
This way, common contains all this logic needed and androidMain and iosMain are just responsible to ask for data to populate the views, in this case a RecyclerView and a UITableViewController accordingly.
- io.ktor:ktor-client-core
- io.ktor:ktor-client-serialization
- org.jetbrains.kotlinx:kotlinx-coroutines-core-common
- Edit local.properties to contain the path to Android SDK
- Open the project with IntelliJ
- Select auto-import
Wait for project to sync.
Compile for Android:
- Go to "Add configuration" and select "Android App"
- Add a name to the configuration (for example "android")
- Select "app" module and click "OK"
Click on Run to compile and install it on your Android device
Compile for iOS
- Open the iosApp/iosApp.xcodeproj from Xcode
Click on Run to compile and install it on your iOS device
If you want to create your first project using Kotlin Multiplatform for Android and iOS you can find this medium post that I've writen here.
We're on the beginning of Kotlin Multiplatform, and there are already amazing projects out there that it take it a bit further, don't forget to give a look at:
