Writing Native Code with Kotlin
If you attempt to compile your project now, you will get a compiler error for each of your expect functions, because you have not provided actual implementations for your shiny new macOS target.
You also need to define an entry point before Doubloons4Gold will function properly under macOS.
The first function you will implement is your formatAsCurrency function. Create a new Kotlin file called Currency.kt, this time in macosX64Main/kotlin.
In your new file, implement the same currency formatting that you set up for the JVM. You will be using some unfamiliar-looking APIs that ship with macOS. We will walk you through the code after you enter it.
Listing 25.2 Natively formatting a number (macosX64Main/kotlin/Currency.kt ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access