# When iOS Engineers Should Use Kotlin Multiplatform's expect/actual Syntax

DevFeed: [When iOS Engineers Should Use Kotlin Multiplatform's expect/actual Syntax](<https://devfeed.tech/articles/why-ios-engineers-should-avoid-this-glorified-kmm-technique-34119.md>)

Original publisher: [Read original article](<https://artandscienceofcoding.com/science/avoid-this-kmm-technique/>)

Author: Derek Lee

Published: 2022-09-22T00:00:00Z

Content type: opinion

Language: en

Sources: [art and science of coding](<https://devfeed.tech/sources/art-and-science-of-coding.md>)

Topics: [kotlin multiplatform mobile](<https://devfeed.tech/topics/kotlin-multiplatform-mobile.md>), [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>)

Tags: [guide](<https://devfeed.tech/tags/guide.md>), [kmm](<https://devfeed.tech/tags/kmm.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [science](<https://devfeed.tech/tags/science.md>)

## AI overview

This article argues that iOS engineers building multiplatform apps with Kotlin Multiplatform Mobile should generally write platform-dependent code in Swift instead of using the expect/actual syntax. It identifies building a multiplatform framework as the main case where the syntax may be worth considering and recommends consulting Apple's Objective-C documentation and Kotlin/Native headers when using it.

## Source excerpt

TL;DR If you're an iOS engineer who wants to build multiplatform apps using KMM, the few benefits of using the expect/actual syntax do not outweigh those of writing your platform-dependent code in Swift. The use-case for iOS engineers to consider leveraging expect/actual syntax would be when building a multiplatform framework. If you're going to use expect/actual, be sure to reference Apple's Objective-C documentation over Swift documentation and use the Kotlin/Native headers for the most accurate representation of the iOS APIs available in Kotlin. The expect/actual Syntax of Kotlin Multiplatform Mobile (KMM) The Kotlin Multiplatform SDK includes a syntactical construct integrated into JetBrains IDEs that engineers can use to define classes and functions that are expect -ed (pun intended) to have platform-specific implementations. The actual implementations are also written in Kotlin separately for Android and iOS. When looking at the code modules in a KMM project: within the KMM shared framework module, you first define a class or a function as expected. Then the actual implementations are written for each supported platform module. The following example illustrates what module the code is defined within for Android and iOS: The `common` module defines the expected classes and functions, and platform modules define the actual implementation. We looked at some simple examples in the last blog. These examples are helpful because they allow us to wrap our heads around the concept before diving into something more complicated. I want to take you on a journey of writing some code using this approach to illustrate how this can become more complicated in practice than expected. In fact, I'm going to make a bold statement and propose that there's only a single scenario where you, the iOS Engineer, should even consider using the expect/actual syntax. This post is part of a series on Kotlin Multiplatform: The iOS Engineer's Guide to Beginning Kotlin Multiplatform Development