DEV Community

Ryan Belz
Ryan Belz

Posted on

Learning Kotlin Multiplatform Mobile: Entry 1

So.... to force myself to not drop this project I am going to attempt to write my experiences while learning using Kotlin Multiplatform Mobile. My GitHub page is starting to become the place where ideas go to die ðŸŦ .

Disclaimer, this is my first ever attempt at documenting really anything but lets get into it.

My interest for KMM has stemmed from working with Xamarin Forms. The code sharing is amazing and I absolutely love C# but if you need to add any frills or flair to your UI, well, you better buckle up and start creating those custom renderers 🚧.

Things that interested me about KMM:

1. Code sharing so you only have to write core code once.

2. Ability to use native cutting edge tech like Jetpack Compose and SwiftUI

3. You can quickly write native code if you need to get the job done. (Kotlin, Swift)
Enter fullscreen mode Exit fullscreen mode

🎉 Here is my experience from 0 to setting up a new project:

TLDR: 8/10 experience. One minor issue while trying to run the iOS App which was quickly fixed searching stack overflow.

I pretty much followed the "Getting started" guide found here word for word.

Step 1: ðŸ’ŧ Setting up my environment

  • Straight forward enough here, I had already had android studio installed (Electric Eel canary build) on my machine with the Kotlin plugins/language pretty much up to date.

  • I, however, had to install the Kotlin Multiplatform plugin for android studio.

KMM Plugin installed

Step 2: ðŸ“Ķ Creating the Project

  • After installing the KMM plugin for android studio I followed the prompts to create a new KMM app and had it created and loaded in a quick minute.

App creation

Step 3: ðŸĪ– Running the Android app

  • Easy as can be, waited for the Gradle sync and build to complete and just hit run in the upper right hand corner!

Android app running fine

Step 4: 🍎 Running the iOS App

  • Now this one was a bit of a pain... When I first switched the configuration to "iosApp" I noticed a red X mark on the picture. After trying to run the app I was shown this error.

ios red x mark

ios error

  • I had to do some googling but this stack overflow post
    here helped to solve the issue.

  • I closed Android studio and ran the following in my terminal and after that my simulator ran just fine.

cd ~/Library/LaunchAgents/
rm com.jetbrains.AppCode.BridgeService.plist
Enter fullscreen mode Exit fullscreen mode

ios app running


🎎 Final thoughts:
All in all it was a pretty straight forward experience with iOS being the problem child like it usually is. It is probably less buggy to run the iOS app directly from Xcode but the fix was not too bad. After the fix I was up and running exploring the project structure and generated code.

Next time I would like to see if I can get something small to work like creating a shared view model. My ultimate goals for the project is to get Firebase Authentication working for both apps and get the app communicating to a Ktor Kotlin backend api for sending and receiving chat messages.

Thanks for reading 👋 and hopefully this does not join the project graveyard anytime soon ðŸŠĶ.

Top comments (0)