0PricingLogin
Kotlin Multiplatform Academy · Lesson

Why expect/actual Exists

The mechanism for platform-specific behavior behind one API.

One Codebase, Different Worlds

Most of your Kotlin runs everywhere, but some tasks need each platform's own tools. That gap is exactly what expect/actual was built to close.

The Problem It Solves

Getting the OS version, a file path, or current time relies on Android or iOS APIs that simply do not exist in shared code. You still want to call them from commonMain. 🤔

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