If you already build Android apps with Kotlin and Jetpack Compose, you know more iOS than you think. Swift and Kotlin were designed in the same years by people who read the same papers, so they look alike: both have optionals, data-like types, closures, extension functions and a modern way of writing asynchronous code. SwiftUI and Compose are cousins too: both describe the screen as a function of state, and both redraw when the state changes.
This lesson is a map between the two worlds. It helps in two directions. If you are an Android developer, it shows you where to look in iOS. If you are an iOS developer, it explains what the Kotlin lessons in the Android course mean. It also helps you answer the common interview question: "What are the differences between the two platforms?"
The languages side by side
- Constants and variables: Kotlin
valandvar; Swiftletandvar. - Null safety: Kotlin
String?with?.,?:and!!; SwiftString?with?.,??and!. Swift'sif letandguard letmatch Kotlin's smart casts and early returns. - Data holders: Kotlin
data classgives equals, copy and toString. Swiftstructis copied by value and gets memberwise initialisers; addEquatable,HashableorCodableas needed. - Sealed types: Kotlin
sealed class; Swiftenumwith associated values. Both give exhaustivewhenandswitch. - Interfaces: Kotlin
interface; Swiftprotocol, which can also have default methods through extensions. - Lambdas: Kotlin
{ x -> x * 2 }; Swift{ x in x * 2 }. Trailing closure syntax exists in both. - Extensions: both let you add functions to existing types.
// Swift
enum LoadState {
case loading
case loaded([String])
case failed(String)
}
func describe(_ state: LoadState) -> String {
switch state {
case .loading: return "Loading..."
case .loaded(let items): return "\(items.count) items"
case .failed(let message): return "Error: \(message)"
}
}
// Kotlin
sealed interface LoadState {
data object Loading : LoadState
data class Loaded(val items: List<String>) : LoadState
data class Failed(val message: String) : LoadState
}
fun describe(state: LoadState): String = when (state) {
LoadState.Loading -> "Loading..."
is LoadState.Loaded -> state.items.size.toString() + " items"
is LoadState.Failed -> "Error: " + state.message
}
The shapes are nearly identical. The biggest practical difference is memory. Kotlin runs on the JVM with a garbage collector. Swift uses ARC, automatic reference counting, so you must think about retain cycles with weak and unowned when closures capture self. The advanced iOS course has a full lesson on it.
The frameworks side by side
- UI: Jetpack Compose and SwiftUI.
@Composablefunctions areViewstructs.remember { mutableStateOf() }is@State. State hoisting is@Binding.Modifierchains are view modifiers, and the order matters in both. - Lists:
LazyColumnisListorLazyVStack.items(list)isForEach. - Navigation: Navigation Compose with a NavHost is
NavigationStackwithnavigationDestination. Bottom navigation isTabView. - State holders:
ViewModelwithStateFlowis an@Observableclass, often marked@MainActor.collectAsStateWithLifecyclehas no equivalent because SwiftUI observes the properties you read. - Async: coroutines and
suspendareasync/await.launchisTask { }.FlowisAsyncSequenceandAsyncStream.viewModelScopeis a Task you cancel yourself or tie to.task. - Networking: Retrofit with kotlinx.serialization is
URLSessionwithCodable. - Database: Room is SwiftData (or Core Data).
@Entityis@Model. A RoomFlowquery is@Query. - Settings: DataStore is
@AppStorageand UserDefaults. Encrypted storage is the Keychain. - Background work: WorkManager is
BGTaskScheduler. Push is Firebase Cloud Messaging on Android and APNs on iOS. - Dependency injection: Hilt is usually plain initialiser injection or the SwiftUI environment in iOS. Heavy frameworks are less common.
- Testing: JUnit and Compose tests are Swift Testing, XCTest and XCUITest.
State and screens: Compose and SwiftUI
// Compose
@Composable
fun Counter() {
var count by remember { mutableIntStateOf(0) }
Button(onClick = { count++ }) {
Text("Tapped " + count + " times")
}
}
// SwiftUI
struct Counter: View {
@State private var count = 0
var body: some View {
Button("Tapped \(count) times") {
count += 1
}
}
}
Both versions are the same idea. The state is owned by the view, the screen is a description of that state, and changing the state redraws the screen. The differences are small: SwiftUI views are structs with a body property, and private on a @State property is a convention that says the view owns it.
What is genuinely different
- Tooling: Android Studio on any desktop system; Xcode only on a Mac. You cannot build iOS apps on Windows or Linux without a Mac.
- Release: Google Play takes an AAB and has a review that is usually quick. The App Store needs an Apple Developer account, signing certificates, TestFlight for betas and a stricter human review. Plan more time for iOS review.
- Device variety: Android has thousands of device models and manufacturer changes. iOS has fewer devices, which makes layout testing easier, but Apple controls which iOS version users run less than you might hope, so always check the minimum version you support.
- Permissions and privacy: both ask at run time. iOS needs a usage description text in Info.plist for each sensitive feature, and App Store review checks it. Apple also asks for privacy manifests and nutrition-label style disclosures.
- Back button and navigation: Android has a system back button. iOS uses a back swipe and the navigation bar, so design the flows differently.
A good learning path for an Android developer is: read the Swift basics lessons quickly, spend time on ARC and value types, build the Calculator and To-Do projects in this course, and then compare the code with the Android versions. Seeing the same app in both languages is the fastest way to make the two feel like one skill.
The same ideas appear in our other mobile courses. The Android Development with Kotlin course builds 21 apps in Kotlin and Compose, and the React Native with Expo course shows one JavaScript codebase for both platforms. When you are ready to go deeper on iOS, continue with the Advanced iOS Development course.
Your task
- Pick one Android project you built, for example the Habit tracker. Build the matching iOS project in this course.
- Write a table of five things you had to change when moving the idea from Kotlin to Swift.
- Re-read the ARC lesson in the advanced course and find where your Android code would have needed
weak self.
How to check it worked
- You can name the Swift equivalent of val, a data class, a sealed class, a coroutine, Room and ViewModel.
- You can explain why SwiftUI needs no collectAsState call.
- You can name two differences in releasing to the App Store and Google Play.