How Kotlin Maps to Objective-C
Understand naming, optionals and class mapping.
How Kotlin Maps to Objective-C is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Kotlin Speaks Obj-C
When you build for iOS, Kotlin compiles into an Objective-C framework. Swift then sees your shared code through that Obj-C lens.
Why Obj-C in the Middle
Swift has no direct Kotlin bridge, but it interops perfectly with Objective-C. So Kotlin targets Obj-C, and Swift reads it from there.
Classes Become Classes
A Kotlin class maps to an Obj-C class of the same name. Swift can construct and use it almost like any native type.
class Greeting {
fun greet(): String = "Hi"
}Functions Become Methods
Top-level Kotlin functions land on a generated helper class, while member functions become methods Swift can call directly.
greeting.greet()Optionals Map to Optionals
A Kotlin nullable type like String? becomes a Swift optional, so you unwrap it with the usual if-let or guard.
fun nickname(): String? = nullWatch the Renames
Some Kotlin names clash with Obj-C rules and get auto-renamed. A trailing underscore or prefix may appear on the Swift side.
Numbers Get Boxed
Kotlin Int and friends arrive in Swift as KotlinInt boxes when nullable or generic. Plain non-null primitives map to native Int.
Companions Show Up
A Kotlin companion object appears in Swift as a static .companion accessor, letting you reach factory functions and constants.
companion object {
fun create() = Greeting()
}Enums and Sealed Types
Kotlin enums become Obj-C-style enums, but sealed classes arrive as a class hierarchy Swift must check with is/as casts.
One Umbrella Header
Everything exported lands under a single framework module you import in Swift, like import shared, exposing all your types.
import sharedMind the Gaps
Not every Kotlin feature survives the bridge cleanly. Knowing this mapping helps you design APIs that feel natural in Swift.
Quick Check
Let us confirm the path Kotlin takes to reach Swift.
Recap
Kotlin compiles to an Obj-C framework: classes map to classes, nullables to optionals, companions to statics. Design with the bridge in mind. 🙂
Frequently asked questions
Is the “How Kotlin Maps to Objective-C” lesson free?
Yes — the full text of “How Kotlin Maps to Objective-C” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “How Kotlin Maps to Objective-C”?
Understand naming, optionals and class mapping. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “How Kotlin Maps to Objective-C” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- How Kotlin Maps to Objective-C
- Suspend Functions as Swift async
- Collect Flows from Swift
- @ObjCName & Swift-Friendly APIs