<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmed Refat on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Refat on Medium]]></description>
        <link>https://medium.com/@ahmedrefatsaid?source=rss-efbc2a38efd7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CR1RIf6_pi8fitf3-0DYKg.jpeg</url>
            <title>Stories by Ahmed Refat on Medium</title>
            <link>https://medium.com/@ahmedrefatsaid?source=rss-efbc2a38efd7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:02:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmedrefatsaid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your National ID Shouldn’t Leave Your Phone: A Private ID Scanner with Apple Vision]]></title>
            <link>https://medium.com/@ahmedrefatsaid/your-national-id-shouldnt-leave-your-phone-a-private-id-scanner-with-apple-vision-530dce3bcd3e?source=rss-efbc2a38efd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/530dce3bcd3e</guid>
            <category><![CDATA[foundation-models]]></category>
            <category><![CDATA[vision-kit]]></category>
            <category><![CDATA[ai-on-device]]></category>
            <category><![CDATA[apple-vision]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Ahmed Refat]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 12:22:05 GMT</pubDate>
            <atom:updated>2026-11-09T12:22:05.784Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I built a private Egyptian national ID scanner with Apple Vision, a 14-digit number, and Foundation Models only where it is safe. Nothing leaves the iPhone.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LFbuLm34WOeiI4tPxrjiA.png" /></figure><h3>Apple’s on-device AI, and the iOS versions behind it</h3><p>Every step of this scanner runs on frameworks that ship inside iOS, with no server and no API key. They arrived over nine years, so the iOS version you target decides what you can use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVi8qyKdvr8hw_OU55bXmg.png" /><figcaption><em>Apple’s on-device vision and language frameworks, by the iOS version that introduced them.</em></figcaption></figure><h3>Vision: image analysis since iOS 11</h3><p>Vision arrived in iOS 11 (2017), together with Core ML. It analyzes images on the device: it detects faces, rectangles, barcodes and documents, and it reads text.</p><ul><li><strong>iOS 13:</strong> text recognition with VNRecognizeTextRequest.</li><li><strong>iOS 15:</strong> document segmentation, which finds a document’s outline in a photo.</li><li><strong>iOS 18:</strong> a Swift-native API built on async/await, with RecognizeTextRequest, DetectFaceRectanglesRequest and ImageRequestHandler.</li><li><strong>iOS 26:</strong> RecognizeDocumentsRequest, which reads a document&#39;s structure.</li></ul><p>On iOS 27.1, text recognition supports 33 languages, Arabic included. In this app, Vision reads the card, finds the holder’s face, and finds the card inside an imported photo.</p><h3>VisionKit: ready-made scanning screens since iOS 13</h3><p>VisionKit arrived in iOS 13 (2019) with VNDocumentCameraViewController, the scanner from the Notes app. It finds a document&#39;s edges, corrects the perspective and captures several pages in one session.</p><p>iOS 16 added DataScannerViewController for live text and barcode scanning, and ImageAnalyzer for Live Text in your own images. In this app, VisionKit is the camera screen that captures the front and the back of the card.</p><h3>Foundation Models: an on-device language model since iOS 26</h3><p>Apple introduced Foundation Models at WWDC25, and it shipped with iOS 26. It gives apps the on-device model that powers Apple Intelligence: about 3 billion parameters, each quantized to 2 bits.</p><ul><li><strong>Text generation</strong> from a prompt, inside a LanguageModelSession.</li><li><strong>Guided generation:</strong> mark a Swift struct @Generable, describe its properties with @Guide, and the model returns that struct.</li><li><strong>Tool calling:</strong> the model can call functions you define in your app.</li><li><strong>iOS 27:</strong> image input, so a prompt can include a picture.</li></ul><p>It needs an Apple Intelligence device, which means an iPhone 15 Pro or newer, with Apple Intelligence turned on. Apple Intelligence itself first shipped in iOS 18.1, in October 2024. In this app, Foundation Models is an optional check of the free-text fields.</p><blockquote>“All of this runs on-device, so all data going into and out of the model stays private.” — Apple, Meet the Foundation Models framework, WWDC25</blockquote><p>Vision and VisionKit run on every iPhone that runs the app. Only the Foundation Models step needs Apple Intelligence hardware.</p><h3>The problem: your ID usually leaves your phone</h3><p>Opening a bank account, an e-wallet or a phone line in Egypt usually starts the same way: scan your national ID. In many of these apps, the photo is uploaded and the text is read on a server.</p><p>That photo is a complete identity profile in one image:</p><ul><li>full name, in Arabic</li><li>home address</li><li>the 14-digit national ID number, which also encodes the birth date</li><li>profession and employer</li><li>gender, religion and marital status</li><li>a face photo</li></ul><p>Here is where each of those fields sits on the card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84N-KiBuwVr0HZIFktoL9g.jpeg" /><figcaption><em>The layout of the Egyptian national ID, front and back: each label marks where a field is printed. Template from </em><a href="https://commons.wikimedia.org/wiki/File:Egyptian_National_Id_Card.png"><em>Wikimedia Commons</em></a><em>, public domain.</em></figcaption></figure><p>Once it is uploaded, copies can live in logs, backups and vendor systems that the user never sees. Reading it on a server also needs a connection, and a server to run and pay for.</p><p>The goal of this project: read every field on the phone and send nothing. If a backend needs the data, the app can send only the fields it needs, never the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvrgKvrrIOo7Y4LCW8ywfA.png" /><figcaption><em>Left: the usual flow, where the image travels to a server. Right: this app, where the image and the text stay on the phone.</em></figcaption></figure><h3>The solution: read the card on the iPhone</h3><p>The scanner is built from layers that all ship with iOS. VisionKit captures the card, Vision reads it, and plain Swift rules turn the text into fields. Foundation Models is an optional extra layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbWj7sxFDdDmbHKYPoyxKg.png" /></figure><p><em>Everything inside the phone runs on the device. There is no network call.</em></p><ul><li><strong>VisionKit</strong> captures the front and the back, already cropped and flattened.</li><li><strong>Vision</strong> reads the Arabic and English text, finds the holder’s face, and finds the card in an imported photo.</li><li><strong>Swift rules</strong> know the card’s layout. They fill the fields and decode the 14-digit ID number.</li><li><strong>Foundation Models</strong> may re-check the free-text fields, using only words Vision actually read.</li><li><strong>SwiftUI</strong> shows the photo and every field, ready to edit.</li></ul><h3>Why the language model is the optional layer</h3><p>My first plan was the obvious one: Vision reads the card, and Foundation Models turns the Arabic text into a typed Swift struct. Before building it, I asked both frameworks one question: do you support Arabic?</p><pre>import Vision<br>import FoundationModels<br><br>let ocr = RecognizeTextRequest()<br>print(ocr.supportedRecognitionLanguages.map(\.maximalIdentifier))<br><br>let model = SystemLanguageModel.default<br>print(model.supportedLanguages.map(\.maximalIdentifier).sorted())<br>print(model.supportsLocale(Locale(identifier: &quot;ar_EG&quot;)))</pre><p>On iOS 27.1, Vision lists ar-Arab-SA among its 33 languages. Foundation Models lists 24 locales covering 15 languages, and Arabic is not one of them: supportsLocale(ar_EG) returns false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*omOI8tcguM66khPmeZBuyQ.png" /><figcaption><em>The probe’s real output: Vision reads Arabic, and the on-device language model does not list it.</em></figcaption></figure><p>The model also needs Apple Intelligence hardware, so it could not be the engine. Vision and Swift rules do the extraction, and Foundation Models gets a narrow, optional job. As the next sections show, that turned out to be the better design anyway.</p><h3>What happens when you tap Scan</h3><p>From the tap to the filled form, each framework has one job. The diagram follows a single scan; each column is one framework, and time runs from top to bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8lBzskprMmdfrlAhCqO7w.png" /></figure><p><em>One scan, step by step, and which framework does each step.</em></p><ol><li><strong>The user taps Scan.</strong> The app presents VisionKit’s VNDocumentCameraViewController.</li><li><strong>VisionKit captures the card.</strong> It finds the card’s edges, corrects the perspective, and captures the front and then the back in one session. A photo picked from the library goes through Vision instead: document segmentation or DetectRectanglesRequest finds the card by its 1.586 : 1 shape, and Core Image flattens it.</li><li><strong>Vision reads the text.</strong> RecognizeTextRequest reads each side in Arabic and English and returns every line with its position. The positions tell the app which way is up.</li><li><strong>Vision finds the face.</strong> DetectFaceRectanglesRequest locates the holder&#39;s photo, and the app crops a passport-style frame around it.</li><li><strong>Swift rules fill the fields.</strong> Header words and the face tell the front from the back. Then the layout gives the first name, the rest of the name, the address, the job, gender, religion, marital status and the dates.</li><li><strong>Swift decodes the ID number.</strong> Birth date, age, sex and birth governorate come out of the 14 digits. The app checks that both sides show the same number and that the card has not expired.</li><li><strong>Foundation Models re-checks the free text (optional).</strong> It sees the OCR lines and the draft, and may move a line to the right field. Every word it returns must come from the OCR.</li><li><strong>SwiftUI shows the result.</strong> Every field is editable, Arabic reads right to left, and badges confirm the checks.</li></ol><p>The OCR request at the heart of step 3 is short:</p><pre>var request = RecognizeTextRequest()<br>request.recognitionLevel = .accurate<br>request.recognitionLanguages = [Locale.Language(identifier: &quot;ar-SA&quot;),<br>                                Locale.Language(identifier: &quot;en-US&quot;)] // the card serial is Latin<br>request.usesLanguageCorrection = true<br>request.minimumTextHeightFraction = 0.012 // card text is small<br><br>let observations = try await ImageRequestHandler(cardImage).perform(request)</pre><h3>The 14 digits that already know your birthday</h3><p>Every Egyptian national ID number follows a fixed recipe, and the recipe encodes facts the card also prints. Here is a fake number, 29001012101235, taken apart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0NEtneXsLiQjgAEPSsK6g.png" /></figure><p><em>Anatomy of an Egyptian national ID number. The example is fake.</em></p><ul><li><strong>Digit 1, century:</strong> 2 means born 1900–1999, 3 means born 2000 or later.</li><li><strong>Digits 2–7, birth date:</strong> 900101 is 1 January 1990.</li><li><strong>Digits 8–9, governorate of birth:</strong> 21 is Giza, and 88 means born abroad.</li><li><strong>Digits 10–13, registration sequence:</strong> the 13th digit is odd for men and even for women.</li><li><strong>Digit 14:</strong> a check digit.</li></ul><p>That changes the whole problem. Birth date, sex and birth governorate need no OCR and no language model. They are decoded, and the decoding checks itself: a month of 13, a 30 February or an unknown governorate code means the OCR misread a digit.</p><pre>// Simplified from NationalIDInfo.swift<br>let d = digits.compactMap(\.wholeNumberValue)  // [2,9,0,0,1,0,1,2,1,0,1,2,3,5]<br>// Simplified from NationalIDInfo.swift<br>let d = digits.compactMap(\.wholeNumberValue)  // [2,9,0,0,1,0,1,2,1,0,1,2,3,5]<br><br>let centuryStart = [2: 1900, 3: 2000][d[0]]    // nil means invalid<br>let birthDate = CardDate(year: (centuryStart ?? 0) + d[1] * 10 + d[2],<br>                         month: d[3] * 10 + d[4],<br>                         day: d[5] * 10 + d[6])  // checked against the calendar<br>let governorate = Governorate.byCode[&quot;\(d[7])\(d[8])&quot;]  // &quot;21&quot; → Giza<br>let sex: Sex = d[12].isMultiple(of: 2) ? .female : .male</pre><p>The number also became my best OCR test. The scanner trusts a run of 14 digits as the ID number only if it decodes to a real person: a valid century, a real date in the past and a known governorate. Anything else is shown with a warning for the user to check. Both sides of the card print the number, so the app also checks that front and back agree.</p><h3>Three surprises along the way</h3><p>The first version passed every upright test card, and three things still surprised me. Each one taught me something about Vision or about Arabic text.</p><h3>1. Vision reads a sideways card perfectly, and that is the problem</h3><p>I rotated a test card by 90 degrees. The ID number was still found, but the name, the address and the job came back empty.</p><p>The cause: RecognizeTextRequest read the text, ID number included, in every orientation I passed it. What changes is the bounding boxes. They are reported in the frame of the orientation you give the request, and my layout rules (“the name is on the right, above the number”) read those boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcDXmlw9_XembzK8pDfTtQ.png" /><figcaption><em>The same sideways card, read with each of the four orientations. The ID number comes back valid every time; only one reading has the layout the right way up.</em></figcaption></figure><p>So the text cannot tell you which way is up. The layout can. On an upright card the lines are wider than they are tall, and Arabic lines line up on the right edge. The app reads once as-is, checks those two facts, and reads a second time only if the card is turned.</p><pre>// Lines wider than tall: the card is level (upright or upside down).<br>// Arabic is right-aligned on the card, so the aligned edge tells the direction.<br>if level &gt;= onSide {<br>    return mean(arabic) { $0.box.minX - (1 - $0.box.maxX) } &gt;= 0 ? .up : .down<br>} else {<br>    return mean(arabic) { $0.box.minY - (1 - $0.box.maxY) } &gt;= 0 ? .left : .right<br>}</pre><p>That is at most two OCR passes instead of four, and all four rotations now pass the tests.</p><h3>2. Arabic has more than one spelling of everything</h3><p>The card prints Arabic-Indic digits (٢٩٠٠…), so every number is converted to 0–9 before any logic runs. Letters vary too: أ, إ and آ are often read as ا, ة as ه, and ى as ي. Before comparing words, the app folds them, so “أعزب” and “اعزب” (single) are the same word.</p><p>Then language correction added diacritics. A name printed “عبد الله” came back as “عبد اللّٰه”, with a shadda and a dagger alef. Cards print names without diacritics, so the app strips them, and the tatweel, from every OCR line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Qy-YeIDUazeHB4_RnNozg.png" /></figure><p><em>Three kinds of variation the app folds away before it compares words.</em></p><pre>switch scalar.value {<br>case 0x064B...0x065F, 0x0670, 0x0640: continue                  // diacritics, tatweel<br>case 0x0622, 0x0623, 0x0625, 0x0671: scalars.append(&quot;\u{0627}&quot;) // آ أ إ ٱ → ا<br>case 0x0649: scalars.append(&quot;\u{064A}&quot;)                          // ى → ي<br>case 0x0629: scalars.append(&quot;\u{0647}&quot;)                          // ة → ه<br>default: scalars.append(scalar)<br>}</pre><h3>3. The header is calligraphy</h3><p>The card’s header, “جمهورية مصر العربية”, is printed in green calligraphy. On the specimen card, Vision read it as “ا وري مصر الجربية”, and the layout rules took that garbled line for the first name, so every field shifted down by one.</p><p>The fix is a rule, not a better font guess: skip everything above the plain “بطاقة تحقيق الشخصية” line, or the top fifth of the card when that line is missing.</p><h3>Foundation Models, used where it is safe</h3><p>The language model still earned a place, as a checker rather than the engine. Layout rules can trip on a two-line job title or an unusual address, and judging text in context is what a language model is good at.</p><p>The rule is strict: the model may only re-assign text that Vision actually read. It never decides the ID number, the dates, gender, religion or marital status. Those stay deterministic.</p><pre>@Generable<br>struct ModelCardFields {<br>    @Guide(description: &quot;Holder&#39;s first name: the name on the first line under the card header. Copied exactly from the OCR lines.&quot;)<br>    var firstName: String<br>@Generable<br>struct ModelCardFields {<br>    @Guide(description: &quot;Holder&#39;s first name: the name on the first line under the card header. Copied exactly from the OCR lines.&quot;)<br>    var firstName: String<br><br>    @Guide(description: &quot;Profession or job title from the back side. Copied exactly. Empty if not printed.&quot;)<br>    var profession: String<br><br>    // familyName, address, employer, husbandName …<br>}<br><br>let session = LanguageModelSession(instructions: instructions)<br>let response = try await session.respond(to: prompt,<br>                                         generating: ModelCardFields.self,<br>                                         options: GenerationOptions(samplingMode: .greedy))</pre><p>The prompt carries the numbered OCR lines from both sides and the draft from the rules. Then every value the model returns goes through a grounding check: each word must appear in the OCR text of that side of the card, or the value is thrown away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFBgLo9kqJ8HndePail8EQ.png" /></figure><p><em>The grounding check: a model answer is used only if every word in it was read from the card.</em></p><pre>let words = ArabicText.words(value)<br>guard !words.isEmpty, words.allSatisfy(readWords.contains) else { return } // no invented text</pre><p>When the model cannot help, the app keeps the rules’ result and says why on the result screen. That covers an ineligible device, Apple Intelligence turned off, and the model declining Arabic input with LanguageModelError.unsupportedLanguageOrLocale. On my synthetic test cards the rules filled every field correctly on their own, so the app works the same with the switch off. When Apple adds Arabic, the same code should start contributing with no changes.</p><h3>The app in action</h3><p>Here is the app reading a specimen card with fake data. Every field is filled in and can be edited, and the badges confirm the checks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GRDb-cJdP44RYeEts5GXA.png" /></figure><p><em>The start screen, and the result: the full name, the ID number and the validation badges. The specimen has no photo, so the photo area stays empty.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asmJNuS20ZV8EgTJ3Gqg-Q.png" /></figure><p><em>Further down: the values decoded from the ID number, and the back of the card with the English meaning under each Arabic word.</em></p><h3>What I would tell you before you build one</h3><ol><li><strong>Check language support before you design.</strong> Three lines of Swift (supportedLanguages, supportsLocale) would have saved me an architecture that could not work.</li><li><strong>Use the structure your document already has.</strong> The 14-digit number gives the birth date, sex and governorate, and it validates the OCR for free. For identity data, rules plus validation beat a language model.</li><li><strong>Treat a language model as an editor, not an author.</strong> Ground every value in what OCR actually read, and keep anything legally meaningful deterministic.</li><li><strong>Test the ugly cases with synthetic data.</strong> Rotated scans and angled photos found bugs that upright scans never would.</li></ol><p>When Apple adds Arabic to Foundation Models, the model’s job can grow. Its image input, new in iOS 27, could also become a second opinion on hard-to-read fields.</p><p>The goal was a scanner that reads everything and uploads nothing. Apple’s on-device frameworks got there, just not the way I first planned.</p><h3>Resources</h3><p><strong>Apple documentation</strong></p><ul><li><a href="https://developer.apple.com/documentation/vision">Vision</a></li><li><a href="https://developer.apple.com/documentation/vision/recognizetextrequest">RecognizeTextRequest</a></li><li><a href="https://developer.apple.com/documentation/visionkit">VisionKit</a></li><li><a href="https://developer.apple.com/documentation/visionkit/vndocumentcameraviewcontroller">VNDocumentCameraViewController</a></li><li><a href="https://developer.apple.com/documentation/foundationmodels">Foundation Models</a></li></ul><p><strong>WWDC sessions</strong></p><ul><li><a href="https://developer.apple.com/videos/play/wwdc2025/286/">Meet the Foundation Models framework</a>, WWDC25</li><li><a href="https://developer.apple.com/videos/play/wwdc2024/10163/">Discover Swift enhancements in the Vision framework</a>, WWDC24</li><li><a href="https://developer.apple.com/videos/play/wwdc2022/10025/">Capture machine-readable codes and text with VisionKit</a>, WWDC22</li><li><a href="https://developer.apple.com/videos/play/wwdc2019/234/">Text Recognition in Vision Framework</a>, WWDC19</li></ul><p><strong>Background</strong></p><ul><li><a href="https://machinelearning.apple.com/research/apple-foundation-models-tech-report-2025">Apple Intelligence Foundation Language Models Tech Report 2025</a>, Apple Machine Learning Research, July 2025</li><li><a href="https://www.apple.com/newsroom/2024/10/apple-intelligence-is-available-today-on-iphone-ipad-and-mac/">Apple Intelligence is available today on iPhone, iPad, and Mac</a>, Apple Newsroom, 28 October 2024</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=530dce3bcd3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Memory Cost of Scrolling in SwiftUI: A VStack vs LazyVStack vs List Breakdown]]></title>
            <link>https://medium.com/@ahmedrefatsaid/the-hidden-memory-cost-of-scrolling-in-swiftui-a-vstack-vs-lazyvstack-vs-list-breakdown-bb3f1adaf8ad?source=rss-efbc2a38efd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb3f1adaf8ad</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[memory-usage]]></category>
            <category><![CDATA[scrollview]]></category>
            <dc:creator><![CDATA[Ahmed Refat]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 10:58:49 GMT</pubDate>
            <atom:updated>2026-02-23T10:58:49.537Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with SwiftUI, displaying scrollable content is one of the most common tasks. At first glance, it looks simple: just wrap your views inside a ScrollView with a VStack. But as soon as you start building real-world apps, you quickly realize that not all scrolling containers are created equal. The way each one handles memory and view lifecycle can make the difference between a smooth experience and a frozen UI.</p><p>So the real question is: which one should you actually use? Let’s break it down.</p><h3>VStack</h3><p>VStack inside a ScrollView renders all child views eagerly, meaning every single item gets created and loaded into memory the moment the view appears — regardless of whether you can see it on screen or not.</p><p>This works perfectly fine for small, static lists. But the moment your dataset grows, you’ll feel it immediately. When tested with 1,000 memory-intensive items, the app froze instantly on launch, and memory spiked to 3.76 GB — because SwiftUI was trying to render everything at once before the UI could even respond.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jikbuTAbbtkIJ_1kDk_dRQ.png" /></figure><h3>LazyVStack</h3><p>LazyVStack was introduced in iOS 14 alongside SwiftUI 2.0 as Apple’s direct answer to a very common problem: VStack’s eager loading behavior was simply not sustainable for dynamic or large lists. The idea was simple — give developers a version of VStack that only does work when it actually needs to.</p><p>So what exactly is LazyVStack? Think of it as a smarter version of VStack. It shares the same layout behavior — it stacks views vertically — but the key difference is <em>when</em> those views get created. LazyVStack only creates a view when it’s about to appear on screen. Once an item scrolls off-screen, its view gets discarded from memory. And if you scroll back up, it simply gets recreated from scratch.</p><p>This lazy behavior keeps the number of active views low at any given time, which is a big win for both memory and scrolling performance compared to a regular VStack. However, one important thing to keep in mind is that LazyVStack doesn’t reuse views — it destroys and recreates them every time. During testing, memory stayed around the 140–150 MB range throughout the scrolling experience and barely dropped even after scrolling back to the top, which shows that the constant creation and destruction of views does leave a footprint over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uaAvuGavjxjCopzB8xUBg.png" /></figure><h3>List</h3><p>List is not new to the Apple ecosystem. In UIKit, the equivalent was UITableView — one of the most performance-optimized components Apple ever built. UITableView had a powerful trick up its sleeve: cell reuse. Instead of creating a new cell every time a row came into view, it would recycle an off-screen cell and simply update its content with new data. This kept memory low and scrolling buttery smooth, no matter how large your dataset was.</p><p>When Apple introduced SwiftUI, they needed something that could bring that same level of efficiency into the new declarative world. That’s exactly what List is. It’s SwiftUI’s equivalent of UITableView, built from the ground up to handle collections of data with the same cell reuse philosophy.</p><p>So how does it work in practice? When an item scrolls off-screen, List doesn’t destroy its view. Instead, it recycles that view and rebinds it to new data when a new row comes into view. This means List avoids the constant overhead of creating and destroying views that LazyVStack suffers from. It also comes with a set of built-in features out of the box — selection, swipe actions, and pull-to-refresh — that would otherwise require manual implementation.</p><p>In terms of memory, List started slightly heavier than LazyVStack before any scrolling happened. But once scrolling began, the real difference became clear. After scrolling through the entire list and back to the top, List reclaimed memory efficiently, dropping down to around 111 MB — a noticeable improvement over LazyVStack, which held onto around 144 MB in the same scenario. That’s the reuse model doing its job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UOO4Nbqn9eFJKoIinjkig.png" /></figure><p><strong>Detailed Comparison Table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lrQT4JqrikwXQSGAjSF8g.png" /></figure><p>The numbers tell the story clearly. LazyVStack starts lighter, but once you start scrolling, it holds onto memory and barely recovers. List, on the other hand, peaks at a similar level during scrolling but reclaims memory efficiently when you scroll back up. That’s the reuse model doing its job, and it’s the reason List is the stronger choice for anything performance-sensitive.</p><h3>Conclusion</h3><p>Each container serves a specific purpose, and choosing the right one depends on your use case.</p><ul><li><strong>VStack</strong> works well for very small, static lists. Once the data starts to grow, it quickly becomes a performance risk.</li><li><strong>LazyVStack</strong> is a step up, creating views on demand and performing well with small to medium datasets — especially when you need full control over layout and styling.</li><li><strong>List</strong> is the best choice for large or performance-critical collections. Its cell reuse keeps memory usage stable, scrolling smooth, and it provides built-in behaviors that would otherwise require significant manual work.</li></ul><p>When in doubt, start with <strong>List</strong>. If you need layout flexibility that List can’t provide, use <strong>LazyVStack</strong>. Only reach for <strong>VStack</strong> when you’re certain the content is small and will stay that way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb3f1adaf8ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your App Icon Is Now a Remote Control — Dynamic iOS Icons Without New Builds]]></title>
            <link>https://medium.com/@ahmedrefatsaid/your-app-icon-is-now-a-remote-control-dynamic-ios-icons-without-new-builds-df5e123ca9cf?source=rss-efbc2a38efd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/df5e123ca9cf</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[alternative-app-icon]]></category>
            <category><![CDATA[firebase-remote-config]]></category>
            <dc:creator><![CDATA[Ahmed Refat]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 23:17:54 GMT</pubDate>
            <atom:updated>2026-02-16T23:17:54.243Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Change your app icon on the fly for Ramadan, Eid, or any event — no App Store review needed.</em></p><p>Have you ever noticed how some apps magically change their icon during holidays or special events? No app update, no download — it just happens. Wouldn’t it be great if your app could do the same?</p><p>In this article, I’ll walk you through exactly how I built this feature using <strong>iOS Alternate App Icons</strong> and <strong>Firebase Remote Config</strong>. The result? A single remote value change in Firebase, and every user’s app icon updates automatically — zero builds, zero reviews.</p><p>Let’s dive in.</p><h3>The Idea</h3><p>iOS has supported alternate app icons since iOS 10.3. You can bundle multiple icons inside your app and switch between them at runtime using UIApplication.shared.setAlternateIconName(_:).</p><p>The missing piece is <strong>deciding which icon to show</strong> — and that’s where Firebase Remote Config comes in. By storing the desired icon key on Firebase, you can change every user’s app icon remotely, whenever you want.</p><h3><strong>Step 1: Prepare Your Alternate App Icons</strong></h3><p>First, you need to design and add the alternate icons to your Xcode project. In the following image, For this example, we’ll have three icons:</p><ul><li><strong>Default</strong> : your regular app icon</li><li><strong>Ramadan : </strong>a themed icon for Ramadan</li><li><strong>Eid : </strong>a themed icon for Eid</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sM1SWLZ8dV9fqPgaf9v47w.png" /></figure><h3><strong>Step 2: Adjusting Xcode’s build settings for alternative icons</strong></h3><p>Go you your project’s Build Settings tab and find ‘Asset Catalog Compiler Options’, then add the row ‘Alternative App Icon Sets’ with the values being a list of the names of every Alternative App Icon you have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rC6dT1SoLoF3TmZMH_tWjQ.png" /></figure><h3><strong>Step 3: Define Your Icon Types</strong></h3><p>Create a clean enum that maps remote config values to icon names. This is the bridge between Firebase and iOS.</p><pre>import Foundation<br><br>enum AppIconType: String, CaseIterable {<br>    case defaultAppIcon = &quot;default&quot;<br>    case ramadanAppIcon = &quot;ramadan&quot;<br>    case eidAppIcon = &quot;eid&quot;<br><br>    /// Returning `nil` tells iOS to revert to the primary (default) icon.<br>    var iconName: String? {<br>        switch self {<br>        case .defaultAppIcon:<br>            return nil<br>        case .ramadanAppIcon:<br>            return &quot;Ramadan&quot;<br>        case .eidAppIcon:<br>            return &quot;Eid&quot;<br>        }<br>    }<br>}</pre><p><strong>Why </strong><strong>nil for the default icon?</strong> Because setAlternateIconName(nil) tells iOS to revert to the primary icon. It&#39;s the built-in convention.</p><h3>Step 4: Set Up Firebase Remote Config</h3><p>If you haven’t already, add Firebase to your project: <a href="https://firebase.google.com/docs/ios/setup">Add Firebase to your Apple project</a></p><p>Then Create the Remote Config parameter</p><p>In the <a href="https://console.firebase.google.com/">Firebase Console</a>:</p><ol><li>Navigate to <strong>Remote Config</strong> under the <strong>Run</strong> section.</li><li>Click <strong>Create</strong> <strong>Configuration </strong>.</li><li>Set the parameter key to app_icon (or whatever key you prefer).</li><li>Set the default value to &quot;default&quot;.</li><li><strong>Publish</strong> the changes.</li></ol><p>That’s it. You can now change this value to &quot;ramadan&quot; or &quot;eid&quot; at any time, and your app will respond accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNegBnDICq8eC7L4i_XZRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1BNzWRfZHVfdclFcPvIsw.png" /></figure><h3>Step 5: Build the Remote Config Manager</h3><p>Here’s the core class that fetches the configuration from Firebase and determines which icon to use.</p><pre>import Foundation<br>import FirebaseRemoteConfig<br><br>final class RemoteConfigManager {<br><br>    static let shared = RemoteConfigManager()<br><br>    private let remoteConfig = RemoteConfig.remoteConfig()<br><br>    private init() {<br>        let settings = RemoteConfigSettings()<br>        settings.minimumFetchInterval = 0<br>        remoteConfig.configSettings = settings<br>    }<br><br>    /// Fetches the `app_icon` key from Remote Config and maps it to an `AppIconType`.<br>    func fetchAppIcon() async -&gt; AppIconType {<br>        do {<br>            let status = try await remoteConfig.fetchAndActivate()<br><br>            switch status {<br>            case .successFetchedFromRemote, .successUsingPreFetchedData:<br>                let value = remoteConfig[&quot;app_icon&quot;].stringValue<br>                return AppIconType(rawValue: value) ?? .default<br>            case .error:<br>                return .default<br>            @unknown default:<br>                return .default<br>            }<br>        } catch {<br>            return .default<br>        }<br>    }<br>}</pre><h3>Step 6: Apply the Icon Change</h3><p>Create a utility that handles the actual icon swap safely.</p><pre>enum AppIconManager {<br>    /// Updates the app icon if the requested icon differs from the current one.<br>    static func updateIcon(to iconType: AppIconType) {<br>        let desiredName = iconType.iconName<br><br>        // Skip if the icon is already set — avoids unnecessary system alerts<br>        guard UIApplication.shared.alternateIconName != desiredName else { return }<br><br>        UIApplication.shared.setAlternateIconName(desiredName) { error in<br>            if let error {<br>                debugPrint(&quot;Failed to change app icon: \(error.localizedDescription)&quot;)<br>            } else {<br>                debugPrint(&quot;App icon changed to: \(iconType.rawValue)&quot;)<br>            }<br>        }<br>    }<br>}</pre><blockquote><strong>Note:</strong> setAlternateIconName shows a system alert to the user confirming the icon change. This is an iOS requirement and cannot be suppressed. There are workarounds floating around, but they rely on private APIs and risk App Store rejection.</blockquote><h3>Step 7: Wire It All Together</h3><pre>func fetchConfigAndUpdateIcon() {<br>    Task {<br>        let iconType = await RemoteConfigManager.shared.fetchAppIcon()<br>        AppIconManager.updateIcon(to: iconType)<br>    }<br>}</pre><p>This calls the convenience method fetchAppIcon() we added to RemoteConfigManager, which handles the entire fetch-and-parse cycle and returns a clean AppIconType value.</p><p>Now trigger it inside your SplashScreen view using .onAppear</p><p>That’s the entire flow. When the app launches, the splash screen fetches the latest config from Firebase, reads the app_icon value, and updates the icon if it&#39;s different from the current one.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcTbBqclj2bU&amp;type=text%2Fhtml&amp;schema=youtu&amp;display_name=YouTube&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcTbBqclj2bU" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c4fb640409cdd76350283c8bb0dba0f/href">https://medium.com/media/3c4fb640409cdd76350283c8bb0dba0f/href</a></iframe><h3>Conclusion</h3><p>Changing your app icon used to mean preparing a new build, waiting for App Store review, and hoping you timed it right. With iOS alternate icons and Firebase Remote Config, that friction disappears entirely.</p><p>The beauty of this architecture is that it’s <strong>completely decoupled</strong>. Your app doesn’t know or care <em>why</em> the icon is changing — it just reads a string from Firebase and responds. This means you can use it for seasonal themes, A/B testing icon designs, regional customization, or even user segmentation with Firebase conditions.</p><p>Once this is in place, every future icon change is a <strong>30-second edit in the Firebase console</strong>. No Xcode, no builds, no reviews.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df5e123ca9cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>