Leanpub Header

Skip to main content

Master Kotlin Multiplatform

Build Production-Ready Android and iOS Apps with Kotlin Multiplatform, Compose Multiplatform, Ktor, Coroutines, and Modern Architecture

Master Kotlin Multiplatform
This book is 100% completeLast updated on 2026-08-19

Build Android and iOS apps without building everything twice. Master Kotlin Multiplatform, Compose Multiplatform, Ktor, Coroutines, Room KMP, Koin, native APIs, testing, and CI/CD through a practical, production-focused approach to modern cross-platform development.

Minimum price

$29.99

$49.99

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Build Android and iOS apps without building everything twice.

Master Kotlin Multiplatform is a practical, hands-on guide to building production-ready Android and iOS applications with Kotlin Multiplatform (KMP) and Compose Multiplatform.

Instead of focusing only on basic demos, this book takes you through the architecture, tools, libraries, and real-world decisions involved in creating a complete multiplatform application.

You'll learn how to share business logic and UI while still taking advantage of the native capabilities of Android and iOS.

What You'll Learn
  • Build and structure a Kotlin Multiplatform project for Android and iOS
  • Create shared UI with Compose Multiplatform
  • Design scalable multiplatform app architecture
  • Build networking layers with Ktor
  • Use Coroutines, Flow, StateFlow, and SharedFlow across platforms
  • Store data locally with Room KMP
  • Implement dependency injection with Koin
  • Build repositories and offline-first applications
  • Master expect / actual and platform-specific abstractions
  • Work with native platform capabilities such as permissions, location, maps, and sensors
  • Integrate native Android and iOS UI when shared UI isn't enough
  • Implement logging, analytics, crash reporting, and error handling
  • Manage configuration, secrets, and feature flags
  • Test multiplatform code effectively
  • Optimize performance, memory usage, and application size
  • Set up CI/CD and release Android and iOS apps
  • Understand Kotlin ↔ Swift interoperability
  • Incrementally migrate an existing Android application to KMP
  • Choose libraries that are safe and practical for multiplatform projects
More Than Just "Hello World"

Kotlin Multiplatform becomes much more interesting when you move beyond a simple shared function.

How should you structure a real app? What belongs in commonMain? When should you use expect/actual? Should the UI be shared? How do you handle native APIs? What happens when you need maps, sensors, permissions, analytics, persistence, or platform-specific UI?

This book focuses on answering those questions.

By the end, you'll understand not only how Kotlin Multiplatform works, but how to make practical architectural decisions when using it in real applications.

Who Is This Book For?

This book is especially useful for:

  • Android developers moving into Kotlin Multiplatform
  • Kotlin developers who want to target Android and iOS
  • Mobile developers exploring Compose Multiplatform
  • Teams considering KMP for an existing Android application
  • Developers who already know KMP basics and want to build production-ready applications

If you already know Kotlin and Android development, you'll feel right at home.

One Kotlin codebase. Two platforms. Native capabilities when you need them.

Master Kotlin Multiplatform and start building Android and iOS applications with a modern, pragmatic approach to shared mobile development.

Share this book

Bundle

Bundles that include this book

Author

About the Author

Mahmoud Ramadan

I am Mahmoud Ramadan. I am Android Tech Lead with 12 years of experience in Android Development.

I developed many apps like chatting, augmented reality, streaming, video calling and more. I am passionate about android programming and teaching. https://www.linkedin.com/in/mahmoud-ramadan-abdelwahed/

Contents

Table of Contents

Chapter 1 — Why Kotlin Multiplatform, Honestly

  1. The problem you already know
  2. What Kotlin Multiplatform actually is
  3. What Compose Multiplatform is, and why it’s a separate decision
  4. The sharing spectrum
  5. How KMP differs from Flutter and React Native
  6. Where KMP genuinely wins
  7. Why Android developers have an unfair advantage right now
  8. Where KMP will let you down (read this part twice)
  9. Why this is a good moment, specifically
  10. The app we’ll build: Atlas
  11. How this book works
  12. What you’ll have by the end
  13. Summary

Chapter 2 — How Kotlin Multiplatform Actually Works

  1. The magic trick, explained
  2. The one idea that unlocks everything: common code vs platform code
  3. Source sets: where your code lives, and what it can see
  4. The source set hierarchy: why iosMain exists
  5. Targets: what your code compiles to
  6. expect/actual: the mechanism for “write once, adapt per platform”
  7. When not to reach for expect/actual (the honest version)
  8. klib: the format that makes shared code shippable
  9. Gradle: how it’s all wired together
  10. Putting it together: the life of a shared function
  11. How this changes the way you’ll code
  12. Summary

Chapter 3 — Setting Up and Running on Both Platforms

  1. The goal, and the shape of getting there
  2. What you’re installing, and why
  3. Installing the toolchain
  4. Verify before you trust: preflight checks and KDoctor
  5. Creating the project with the wizard
  6. The anatomy of what you got
  7. Running on Android: the easy win
  8. Surviving your first Xcode encounter
  9. Running on iOS
  10. What just happened
  11. When the first run goes sideways
  12. Summary

Chapter 4 — Compose Multiplatform Fundamentals

  1. The good news, stated plainly
  2. The shape of a Compose Multiplatform app
  3. Previews now work in common code
  4. What’s genuinely different on iOS
  5. Building Atlas’s first shared screen
  6. A first taste of resources
  7. Summary

Chapter 5 — Design System, Theming, and Resources

  1. Why a design system, and why define it once
  2. Atlas’s color scheme, light and dark
  3. Typography and custom fonts
  4. Images and the resources system in depth
  5. Strings, localization, and right-to-left
  6. Adapting to screen size
  7. Summary

Chapter 6 — Navigation and App Structure

  1. The navigation problem, and why it’s harder here
  2. The landscape, and Atlas’s choice
  3. Setting up navigation
  4. Type-safe routes
  5. Atlas’s navigation graph
  6. The bottom navigation bar
  7. The iOS realities you must respect
  8. Summary

Chapter 7 — Architecture for a Multiplatform App

  1. Why architecture matters more here
  2. The layers
  3. The dependency rule
  4. What lives in common versus platform
  5. The multiplatform ViewModel
  6. Modeling UI state
  7. Unidirectional data flow
  8. Atlas’s blueprint
  9. Summary

Chapter 8 — Networking with Ktor

  1. Ktor’s shape: core in common, engine per platform
  2. Configuring a production-grade client
  3. Modeling the data: DTOs
  4. DTO to domain: why the boundary exists
  5. Making the call: the remote data source
  6. Error handling that survives reality
  7. Authentication
  8. Wiring the seam shut
  9. Summary

Chapter 9 — Coroutines and Flow Across Platforms

  1. The good news: coroutines are multiplatform
  2. Structured concurrency, and why it matters more here
  3. Dispatchers across platforms
  4. Flow: the reactive backbone
  5. The iOS consumption problem
  6. SKIE: making Kotlin feel native in Swift
  7. Where this leaves Atlas
  8. Summary

Chapter 10 — Local Persistence with Room KMP

  1. Why a local database, and why Room
  2. Setting up Room for KMP
  3. Entities: pure Kotlin in commonMain
  4. DAOs: reactive queries in shared code
  5. The database class and the constructor mechanism
  6. The one platform leaf: the database builder
  7. Type converters and migrations
  8. Summary

Chapter 11 — Dependency Injection with Koin

  1. The problem DI solves
  2. Why Koin
  3. Modules: declaring how things are built
  4. The platform module: the bridge for platform leaves
  5. Initializing Koin
  6. Koin and Compose: resolving ViewModels
  7. Koin on the native iOS side
  8. Summary

Chapter 12 — Repositories and Offline-First

  1. The offline-first principle
  2. Single source of truth
  3. The cache-then-network pattern
  4. Modeling result state honestly
  5. Atlas’s offline-first repository
  6. The Saved feature: offline by nature
  7. Staleness: when to refresh
  8. A note on testing offline behavior
  9. Summary

Chapter 13 — expect/actual in Depth and Platform Abstractions

  1. What you already know, made systematic
  2. expect/actual in depth
  3. The limits, now concrete
  4. The better default: interface + DI
  5. The decision rule
  6. Designing a clean platform abstraction
  7. The template Part IV will follow
  8. Summary

Chapter 14 — Permissions and Platform Services

  1. Why permissions deserve their own chapter
  2. Two models, genuinely different
  3. The unified approach: moko-permissions
  4. Platform setup you cannot skip
  5. Requesting permission from Compose
  6. Atlas’s permission gate
  7. Permission UX principles
  8. Summary

Chapter 15 — Location

  1. The template, made concrete
  2. The Android implementation
  3. The iOS implementation
  4. Binding and consuming
  5. Accuracy versus battery
  6. Practical realities
  7. Summary

Chapter 16 — Maps

  1. Why maps are the honest limit of shared UI
  2. The interop primitives
  3. The map decision: MapKit on iOS, Google Maps on Android
  4. The common declaration and Android side
  5. The iOS side: MapKit through UIKitView
  6. Bridging a third-party SDK: the Google-Maps-on-iOS pattern
  7. Markers, camera, and the route foundation
  8. Interop gotchas
  9. Summary

Chapter 17 — Sensors

  1. Sensors are streams
  2. The Android side: SensorManager and friends
  3. The iOS side: CoreMotion
  4. Binding, and the battery reality
  5. Availability: not every device has every sensor
  6. Putting it together: route tracking
  7. Summary

Chapter 18 — Native UI Interop: The Escape Hatch

  1. The escape hatch is a feature, not a failure
  2. The four directions of interop
  3. Embedding native inside Compose
  4. Embedding Compose inside native (incremental adoption)
  5. Calling platform-only and third-party SDKs
  6. Sharing state across the boundary
  7. Memory: respect the boundary
  8. When not to use the escape hatch
  9. Summary

Chapter 19 — Logging

  1. Why logging earns a chapter
  2. Kermit: the multiplatform logger
  3. Levels and tags
  4. Logging discipline
  5. Integrating with networking and errors
  6. Release versus debug
  7. Summary

Chapter 20 — Analytics and Crash Reporting

  1. Production observability is a different problem
  2. Analytics: a clean event taxonomy
  3. Crash reporting: the honest landscape
  4. The iOS symbolication problem
  5. Privacy and consent
  6. Wiring it together
  7. Summary

Chapter 21 — Error Handling and Resilience

  1. Resilience is a property, not a feature
  2. The app-wide error model
  3. Mapping errors to humane UI
  4. Retry and backoff
  5. Offline-first as resilience
  6. Graceful degradation
  7. The boundary discipline
  8. Summary

Chapter 22 — Configuration, Secrets, and Feature Flags

  1. Why configuration is a production concern
  2. Compile-time config with BuildKonfig
  3. Secrets: the rules
  4. Secure runtime storage: the token leaf, finally
  5. Feature flags
  6. The debug menu
  7. Summary

Chapter 23 — Testing Multiplatform Code

  1. Why testing matters more in multiplatform
  2. A strategy, not a coverage number
  3. Unit tests in common code
  4. Fakes over mocks
  5. Repository and ViewModel tests
  6. Compose Multiplatform UI tests
  7. Summary

Chapter 24 — Performance, App Size, and Memory

  1. Performance is a feature, and a measured one
  2. iOS binary size
  3. Startup time
  4. Compose performance
  5. Memory and leaks
  6. Profiling on both platforms
  7. Summary

Chapter 25 — CI/CD and Releasing Both Apps

  1. The shipping problem
  2. Continuous integration: catch problems before they ship
  3. Building and signing
  4. Automating with Fastlane
  5. The two store pipelines
  6. Don’t forget the dSYMs
  7. A release checklist
  8. Summary
  9. You built a production app

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub