NibQuest

How it teaches

One Kotlin codebase for a kids' learning app on Android and iOS

NibQuest runs the same curriculum, the same mastery rules and the same screens on Android phones, iPhones and iPads. Here's how the code is split, and the parts that still give me trouble.

I make NibQuest on my own. It's a math and reading app for kids from Pre-K to 7th grade, with 330 skills, and it's on Google Play and the App Store. One person can't keep two copies of a curriculum in step, so almost everything is written once in Kotlin. Android runs it natively. iOS gets it as a framework built with Kotlin/Native, and Compose Multiplatform draws the screens on both.

This isn't a getting-started guide. JetBrains has good ones. It's the set of decisions that held up after two store launches, written down for anyone weighing the same setup.

Where the lines of code live

I counted on 21 November 2026, source only, tests and generated code left out.

ModuleWhat's in itLines
shared/coreCurriculum, question generators, mastery, reviews, learning records, save formatabout 52,200
shared/gameApp state, every screen and activity, drawing, animation, the grown-ups areaabout 13,600
android/platformText-to-speech, audio, files, sharing, RevenueCatabout 1,350
ios/platformThe same jobs for iOS, written in Kotlin against Apple's APIsabout 1,100
ios (Swift)The host app: launch, lifecycle, the view controllerabout 600

So roughly 95% is shared. Most of core is content, not logic. Each skill is a Kotlin definition with its questions, hints, mix-ups and standard codes. It's long, but it's dull to read, and that's how I want it.

Why the rules can't fork

A parent can move a child's progress from an Android tablet to an iPad. If the two apps disagreed by even one rule about when a skill counts as learned, the same file would show different checkmarks on each device. Parents notice that and stop trusting the app.

So the rules live in core, which has no idea which platform it's on. It depends on kotlinx.serialization and one bignum library, and nothing else. The save file is a serialized data class. Both apps read and write it with the same code.

Keep the platform seams small

Everything the shared code needs from the phone goes through a short list of expect declarations in shared/game:

expect fun createVoice(): Voice
expect fun createMusic(): Music
expect fun createSfx(): Sfx
expect fun createStore(): Store
expect object Billing { /* ... */ }
expect object Platform { /* ... */ }

Voice, Music and the rest are ordinary interfaces. The Android actual wraps TextToSpeech and SoundPool. The iOS actual is also Kotlin, calling AVSpeechSynthesizer and AVFoundation through the platform bindings Kotlin/Native ships with. That's why there's so little Swift. I only write Swift where Xcode insists on it.

The rule I keep: a seam passes plain data and callbacks, never platform types. Voice.say() takes a list of lines with a speaker and some text. It doesn't know what an utterance object is. When a seam starts to want more, that usually means some logic is leaking into platform code and should move back into shared.

Decimals without Double

Fourth and fifth graders work with decimals, and the app checks their answers. A checker that thinks 0.1 + 0.2 is 0.30000000000000004 isn't usable. On the JVM I'd reach for BigDecimal, but common Kotlin doesn't have it.

So core has a small ExactDecimal class: a BigInteger plus a count of decimal places, built on com.ionspin.kotlin:bignum. Adding lines up the places first. Dividing reduces the fraction and then checks that the denominator has no prime factors other than 2 and 5. If it does, the answer would never terminate, and the class throws instead of rounding quietly:

while (b % TWO == ZERO) { b /= TWO; twos++ }
while (b % five == ZERO) { b /= five; fives++ }
if (b != ONE) throw ArithmeticException("Non-terminating decimal expansion")

That throw is a feature. A question generator that would produce 1 ÷ 3 as a "decimal" problem fails a unit test, and never reaches a child.

Mastery as plain data

NibQuest counts a skill as learned after three answers given without a hint, and at most two of them can come on the same day. So every learned skill has been shown on at least two different days. Here's the whole rule:

@Serializable
data class TargetHits(val count: Int = 0, val day: Long = -1,
                      val today: Int = 0, val days: Int = 0) {
    fun tick(at: Long): TargetHits {
        val d = at / Mastery.DAY
        return when {
            d != day -> TargetHits(count + 1, d, 1, days + 1)
            today >= Mastery.TARGET_PER_DAY -> this
            else -> copy(count = count + 1, today = today + 1)
        }
    }
}

Memory checks come back after 20 hours, then 3, 7, 21 and 60 days. A missed check reopens the skill. Alongside the counts there's a small Bayesian knowledge-tracing estimate. If the child asked for a hint before their first try, that answer doesn't move the estimate at all.

None of this touches a clock, a database or a screen. The time comes in as a parameter. That means the core tests run on the JVM in a few seconds, with no emulator or simulator, and they cover both platforms at once. There are 127 of them right now. They're the reason I can change a rule on a Saturday morning and ship it to both stores the same week.

Making a speech engine read math

Young kids can't read the instructions, so everything is read aloud with the voices already on the device. System speech engines are built for prose. Give one "3/4" and you might hear "three slash four", or a date.

So the shared Voice code rewrites text before any platform sees it. Fractions become words ("three quarters"), and emoji and other picture characters are stripped out so the engine doesn't read their names. Because this happens in shared code, a fix lands on both platforms at once. The only thing that differs between Android and iOS is which voices are installed.

What still bites

Would I do it this way again?

Yes. The cost is real: you still need a Mac and Xcode, Gradle builds for iOS are slow, and debugging on iOS is a step removed from the code. But the alternative was two curricula drifting apart, and for an app whose whole promise is "this checkmark means your child really knows it", that wasn't an option.

If you're building something similar, my one piece of advice is to put the rules that matter in a module that can't see the platform at all, and test that module hard. The UI sharing is nice. That module is what actually saves you time.

Questions, or spotted something wrong? Email [email protected]. I read everything.