<?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: João from UMDIA</title>
    <description>The latest articles on DEV Community by João from UMDIA (@umdia).</description>
    <link>https://dev.to/umdia</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%2F4283509%2F09d36138-a0ed-4063-a33f-d0dc97cb4c2e.png</url>
      <title>DEV Community: João from UMDIA</title>
      <link>https://dev.to/umdia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/umdia"/>
    <language>en</language>
    <item>
      <title>Three bugs I shipped in a Capacitor iOS app, and how small the fixes were</title>
      <dc:creator>João from UMDIA</dc:creator>
      <pubDate>Fri, 04 Dec 2026 20:46:29 +0000</pubDate>
      <link>https://dev.to/umdia/three-bugs-i-shipped-in-a-capacitor-ios-app-and-how-small-the-fixes-were-5g4j</link>
      <guid>https://dev.to/umdia/three-bugs-i-shipped-in-a-capacitor-ios-app-and-how-small-the-fixes-were-5g4j</guid>
      <description>&lt;p&gt;I build UMDIA, an iPhone app for learning European Portuguese. It's React and Vite wrapped in Capacitor, with Firebase behind it. The web-to-native setup has been good to me, but it has a few traps that don't show up in the browser. These three made it into App Store builds before I caught them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A Capacitor plugin returned from a promise calls &lt;code&gt;.then&lt;/code&gt; on the native side
&lt;/h2&gt;

&lt;p&gt;App Check never worked in version 1.0. No crash and no visible error: the token request just never happened. The cause was this pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loadAppCheck&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;FirebaseAppCheck&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'@capacitor-firebase/app-check'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;FirebaseAppCheck&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;FirebaseAppCheck&lt;/span&gt; &lt;span class="c1"&gt;// the bug&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Capacitor plugin is a &lt;code&gt;Proxy&lt;/code&gt;. Any property you read on it becomes a call to a native method. When an async function returns a value, JavaScript checks whether that value is a thenable by reading &lt;code&gt;.then&lt;/code&gt;. On the proxy, that read turns into a native call, and iOS answers with &lt;code&gt;FirebaseAppCheck.then() is not implemented on ios&lt;/code&gt;. The promise rejects, and if nothing logs it, the feature silently does nothing.&lt;/p&gt;

&lt;p&gt;The fix is to never let the plugin be the value of a promise. Wrap it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;plugin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FirebaseAppCheck&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same thing applies to any plugin you lazy-load, so I now wrap the text-to-speech plugin the same way. If you see "&lt;code&gt;.then()&lt;/code&gt; is not implemented" in a Capacitor log, this is almost certainly it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;code&gt;sort(() =&amp;gt; Math.random() - 0.5)&lt;/code&gt; is not a shuffle
&lt;/h2&gt;

&lt;p&gt;The quiz and flashcards kept showing the same words, and the correct answer landed in the first slots more often than it should. I had shuffled with the classic one-liner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;shuffled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A comparator that returns random results breaks the assumptions of the sort algorithm. The output depends on the engine's sort implementation, and it's biased: items tend to stay near where they started. With a dictionary in alphabetical order, the early words won far more often than the late ones.&lt;/p&gt;

&lt;p&gt;Fisher-Yates gives every ordering the same probability, and it's six lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rnd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&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;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&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;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;rnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&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;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Passing &lt;code&gt;rnd&lt;/code&gt; in also makes it testable: give it a seeded generator and check the distribution over many runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The iPhone voice spelled out "NIF"
&lt;/h2&gt;

&lt;p&gt;The app pronounces words with the system's speech synthesis, using the European Portuguese voice. That means no audio files, it works offline and it covers the whole dictionary. One problem: Portuguese reads some acronyms as words. Your tax number, the NIF, is said "nif", one syllable. The voice said "N, I, F".&lt;/p&gt;

&lt;p&gt;Lower case didn't help. The voice still spelled "nif", and I could hear it, but I also measured it: "o nif" took longer to say than "o ene i efe". So the next update swaps a few acronyms for a spelling the voice reads as a word before speaking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;ACRONYMS_AS_WORDS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;NIF&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'nife'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;IBAN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'iban'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;CEP&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cep'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"nife" rhymes with "bife", and the final "e" in European Portuguese is almost silent, so it comes out as "nif". It's a hack, but a deliberate one with a test next to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The common thread
&lt;/h2&gt;

&lt;p&gt;None of these showed up in the desktop browser during development. Two of them only exist on a real device, and the third only shows up as a pattern over hundreds of rounds. What helped most was writing a small test for each one once I understood it, so they stay fixed.&lt;/p&gt;

&lt;p&gt;If you're learning European Portuguese, or you're curious what a Capacitor app looks like in the App Store, UMDIA is free to start: &lt;a href="https://apps.apple.com/app/id6819083275?pt=129560377&amp;amp;ct=devto&amp;amp;mt=8" rel="noopener noreferrer"&gt;App Store&lt;/a&gt; · &lt;a href="https://umdia.co" rel="noopener noreferrer"&gt;umdia.co&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>capacitor</category>
      <category>ios</category>
      <category>react</category>
    </item>
  </channel>
</rss>
