Created by Paris Tsiogas, Head of Mobile Development @ Desquared August 26, 2025

Intro

This guide walks you through implementing an encrypted Room database in a Kotlin Multiplatform (KMP) project, supporting both Android and iOS using SQLCipher. It covers Gradle, dependencies, code structure, and platform-specific setup.

1. Dependencies & Gradle Setup

1.1. Add Room & SQLCipher to Gradle/TOML

In your libs.versions.toml:

[versions]
sqlcipher = "4.9.0"
room = "2.7.0"
ksp = "2.1.21-2.0.2"
androidx-sqlite = "2.5.2"

[libraries]
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
room-common = { module = "androidx.room:room-common", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
androidx-sqlite = { module = "androidx.sqlite:sqlite", version.ref = "androidx-sqlite" }
androidx-sqlite-framework = { module = "androidx.sqlite:sqlite-framework", version.ref = "androidx-sqlite" }
android-sqlcipher = { module = "net.zetetic:sqlcipher-android", version.ref = "sqlcipher" }

In your plugins section:

[plugins]
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
androidx-room = { id = "androidx.room", version.ref = "room" }

1.2. Android Gradle

Add to your Android module's build.gradle.kts:

dependencies {
		// ...other dependencies
    implementation(libs.room.runtime)
}

1.3. iOS Podfile

Add to your iOS project:

pod 'SQLCipher', '~> 4.8.0'

2. KMP Shared Module Setup

2.1. Plugins & Cocoapods

In your root build.gradle.kts add:

plugins {
	...
	alias(libs.plugins.kotlinCocoapods) apply false
}

In your shared module's build.gradle.kts: