expect and actual
Platform-specific implementations.
The Need for Platform Code
Some functionality has no common implementation — getting the OS name, a UUID, or the current platform. KMM solves this with the expect/actual mechanism.
expect Declarations
In commonMain you declare an expect function or class — a contract with no body. Common code can call it.
// commonMain
expect fun platformName(): StringAll lessons in this course
- KMM Project Structure
- expect and actual
- Sharing Business Logic
- Platform APIs