Both languages share similar ideologies because they’re looking to solve the same problems created by their predecessors.
It’s a great time to be an iOS developer in the KMP open-source community because iOS experience is in demand.
Kotlin isn’t going anywhere in the Android world. The worst case scenario for an iOS dev is that KMP code sharing doesn’t take off, and they’re left with Kotlin and Android Studio experience under their belt.
Kotlin Multiplatform is optimized for sharing up until the platform’s native UI; it leaves the stuff that iOS developers hold important untouched.
Kotlin has excellent interop. It allows for optional code sharing. It’s also modular in its approach to working with existing apps. You can try one small piece of code without impacting the rest of the iOS app.
If you’d like to troubleshoot or ask questions related to our kit for iOS developers, first request to join the JetBrains Kotlinlang Slack and then search and join the “kampkit-support” channel.
See you in Slack!
Our tutorial provides instructions to help iOS devs get KMP running as fast as possible
Introductory information on KMP and Kotlin/Native.
Plugin to facilitate debugging iOS applications using Kotlin Native in Xcode
DRY (or Don’t Repeat Yourself) is one of the foundational principles of programming, but repeating lots of logic has been often necessary to develop an app running on multiple platforms.
Trying to minimize repetition is just good programming. And more shared code across platforms means less repetition, which means better code.
Think about your iOS current project: is it available on any other platforms, like Android or the web? If so: how much logic does your iOS app share with its counterparts on those other platforms? If not, but making your app available on another platform is on the roadmap, how much will developing on the next platform force you to repeat yourself? Either way, the answer is probably: a lot.
Enter Kotlin Multiplatform (KMP). Kotlin is a statically-typed programming language that bears a striking resemblance to Swift, and is 100% interoperable with Java. In many ways, it’s Swift for Android. KMP is a feature of Kotlin which shares code between an app’s various platforms, so that each platform’s natively programmed UI calls into the common code. KMP is not the final step to accomplishing 100% shared code across all platforms, but it is the natural next step towards that goal.
KMP works by using Kotlin to program business logic that is common to your app’s various platforms. Then, each platform’s natively programmed UI calls into that common logic. UI logic must still be programmed natively in many cases because it is too platform-specific to share. In iOS this means importing a .frameworkfile – originally written in KMP – into your Xcode project, just like any other external library. You still need Swift to use KMP on iOS, so KMP is not the end of Swift.
KMP can also be introduced iteratively, so you can implement it with no disruption to your current project. It doesn’t need to replace existing Swift code. Next time you implement a feature across your app’s various platforms, use KMP to write the business logic, deploy it to each platform, and program the UIs natively. For iOS, that means business logic in Kotlin and UI logic in Swift.
The close similarities between Swift’s and Kotlin’s syntax greatly reduces a massive part of the learning curve involved with writing that KMP business logic. What’s left in that learning curve is the IDE: Android Studio.
Mobile, The Walt Disney Company