0PricingLogin
Kotlin Multiplatform Academy · Lesson

Get the Platform Name per Target

A classic expect/actual function for Android and iOS.

The Hello World of KMP

Returning the platform name is the classic first expect/actual you write. It proves your shared module really runs on both apps. 👋

Declare the expect

Start in commonMain with an expect function that returns a String. No body yet, just the shape both platforms agree on.

expect fun platform(): String

All lessons in this course

  1. Why expect/actual Exists
  2. Get the Platform Name per Target
  3. expect/actual Classes & Properties
  4. Common Mistakes & Compiler Errors
← Back to Kotlin Multiplatform Academy