<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TwoLogPI Apps</title>
    <description>The latest articles on DEV Community by TwoLogPI Apps (@twologpi_apps_d10675e955e).</description>
    <link>https://dev.to/twologpi_apps_d10675e955e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4257155%2F9ee550ee-2247-4bdd-82e4-29d0b1e8f091.png</url>
      <title>DEV Community: TwoLogPI Apps</title>
      <link>https://dev.to/twologpi_apps_d10675e955e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/twologpi_apps_d10675e955e"/>
    <language>en</language>
    <item>
      <title>One Kotlin codebase for a kids' learning app on Android and iOS</title>
      <dc:creator>TwoLogPI Apps</dc:creator>
      <pubDate>Sat, 21 Nov 2026 10:51:44 +0000</pubDate>
      <link>https://dev.to/twologpi_apps_d10675e955e/one-kotlin-codebase-for-a-kids-learning-app-on-android-and-ios-2go8</link>
      <guid>https://dev.to/twologpi_apps_d10675e955e/one-kotlin-codebase-for-a-kids-learning-app-on-android-and-ios-2go8</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the lines of code live
&lt;/h2&gt;

&lt;p&gt;I counted on 21 November 2026, source only, tests and generated code left out.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;What's in it&lt;/th&gt;
&lt;th&gt;Lines&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;shared/core&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Curriculum, question generators, mastery, reviews, learning records, save format&lt;/td&gt;
&lt;td&gt;about 52,200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;shared/game&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;App state, every screen and activity, drawing, animation, the grown-ups area&lt;/td&gt;
&lt;td&gt;about 13,600&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;android/platform&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Text-to-speech, audio, files, sharing, RevenueCat&lt;/td&gt;
&lt;td&gt;about 1,350&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ios/platform&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The same jobs for iOS, written in Kotlin against Apple's APIs&lt;/td&gt;
&lt;td&gt;about 1,100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ios&lt;/code&gt; (Swift)&lt;/td&gt;
&lt;td&gt;The host app: launch, lifecycle, the view controller&lt;/td&gt;
&lt;td&gt;about 600&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So roughly 95% is shared. Most of &lt;code&gt;core&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the rules can't fork
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;So the rules live in &lt;code&gt;core&lt;/code&gt;, 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the platform seams small
&lt;/h2&gt;

&lt;p&gt;Everything the shared code needs from the phone goes through a short list of &lt;code&gt;expect&lt;/code&gt; declarations in &lt;code&gt;shared/game&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;createVoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Voice&lt;/span&gt;
&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;createMusic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Music&lt;/span&gt;
&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;createSfx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Sfx&lt;/span&gt;
&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;createStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Store&lt;/span&gt;
&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Billing&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Platform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Voice&lt;/code&gt;, &lt;code&gt;Music&lt;/code&gt; and the rest are ordinary interfaces. The Android &lt;code&gt;actual&lt;/code&gt; wraps &lt;code&gt;TextToSpeech&lt;/code&gt; and &lt;code&gt;SoundPool&lt;/code&gt;. The iOS &lt;code&gt;actual&lt;/code&gt; is also Kotlin, calling &lt;code&gt;AVSpeechSynthesizer&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;The rule I keep: a seam passes plain data and callbacks, never platform types. &lt;code&gt;Voice.say()&lt;/code&gt; 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 &lt;code&gt;shared&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decimals without Double
&lt;/h2&gt;

&lt;p&gt;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 &lt;code&gt;BigDecimal&lt;/code&gt;, but common Kotlin doesn't have it.&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;core&lt;/code&gt; has a small &lt;code&gt;ExactDecimal&lt;/code&gt; class: a &lt;code&gt;BigInteger&lt;/code&gt; plus a count of decimal places, built on &lt;code&gt;com.ionspin.kotlin:bignum&lt;/code&gt;. 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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="no"&gt;TWO&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="no"&gt;TWO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;twos&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;ZERO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="n"&gt;five&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;fives&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;ONE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nc"&gt;ArithmeticException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Non-terminating decimal expansion"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mastery as plain data
&lt;/h2&gt;

&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Serializable&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TargetHits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Long&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;tick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TargetHits&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;Mastery&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DAY&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;TargetHits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nc"&gt;Mastery&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;TARGET_PER_DAY&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making a speech engine read math
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;So the shared &lt;code&gt;Voice&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  What still bites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A crash I can't fix myself.&lt;/strong&gt; On iOS, Compose Multiplatform 1.9.3 sometimes crashes during rotation inside its own layout code ("List is empty" from &lt;code&gt;DepthSortedSet&lt;/code&gt;). It looks like JetBrains issue CMP-8935. I can reproduce it now and then on an iPad simulator, never on demand. The fix is a framework upgrade, so I'm waiting on that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tablets aren't "wide phones".&lt;/strong&gt; My first tablet layouts keyed off the window width class. Big phones in landscape hit the expanded class too, and their layouts changed when they shouldn't have. Now every tablet branch checks the shortest side of the window (600dp or more), so a rotated phone stays a phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not every screen is yours.&lt;/strong&gt; On Android the plans screen is RevenueCat's hosted paywall. Its tablet layout lives in their dashboard, not in my code. On iOS that screen is my own Compose code. Two platforms, two places to make the same change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;iOS stack traces.&lt;/strong&gt; A Kotlin exception on iOS shows up as a &lt;code&gt;SIGABRT&lt;/code&gt; with a Kotlin trace buried underneath. While I was chasing the rotation crash, I added a temporary unhandled-exception hook just to print readable traces, then took it out again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Would I do it this way again?
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Happy to answer questions in the comments. If you want to see the app itself, it's at &lt;a href="https://nibquest.com/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=engineering_kmp_article" rel="noopener noreferrer"&gt;nibquest.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post first appeared on &lt;a href="https://nibquest.com/engineering/kotlin-multiplatform-kids-app/" rel="noopener noreferrer"&gt;nibquest.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>kmp</category>
      <category>android</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
