<?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 Hojun Rooney Baek on Medium]]></title>
        <description><![CDATA[Stories by Hojun Rooney Baek on Medium]]></description>
        <link>https://medium.com/@hojunrooneybaek?source=rss-9c8ed2e3abaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZN2XX6b9ehNET6zW</url>
            <title>Stories by Hojun Rooney Baek on Medium</title>
            <link>https://medium.com/@hojunrooneybaek?source=rss-9c8ed2e3abaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:19:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hojunrooneybaek/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[Turn Claude into an AI QA Engineer with Playwright (Complete Guide)]]></title>
            <link>https://medium.com/@hojunrooneybaek/turn-claude-into-an-ai-qa-engineer-with-playwright-complete-guide-611007f88eb5?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/611007f88eb5</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[playwrigh]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 06:01:43 GMT</pubDate>
            <atom:updated>2026-03-12T06:01:43.049Z</atom:updated>
            <content:encoded><![CDATA[<p>AI coding assistants are rapidly transforming how developers build software. Tools like Claude can generate code, refactor logic, and debug issues faster than ever.</p><p>But one area that is still surprisingly underused is <strong>AI-driven browser automation</strong>.</p><p>By combining Claude Code with the official <strong>Playwright plugin</strong>, you can turn Claude into something much more powerful:</p><p><strong>An AI-powered QA engineer capable of testing your web applications automatically.</strong></p><p>In this guide, we’ll walk through how to use the Playwright plugin with Claude Code to automate browser testing, generate E2E tests, and debug UI issues.</p><h3>Why Combine Claude and Playwright?</h3><p>Traditionally, frontend testing workflows look like this:</p><pre>Write UI code<br>↓<br>Manually test the UI<br>↓<br>Write Playwright tests<br>↓<br>Fix bugs</pre><p>But with Claude and Playwright, the workflow becomes:</p><pre>Claude writes code<br>↓<br>Claude generates Playwright tests<br>↓<br>Claude runs browser automation<br>↓<br>Claude detects bugs<br>↓<br>Claude fixes the code</pre><p>This creates an <strong>AI-driven development loop</strong> that dramatically speeds up debugging and UI testing.</p><h3>What is the Playwright Plugin for Claude?</h3><p>Playwright is a powerful browser automation tool developed by Microsoft. It allows developers to programmatically control browsers like:</p><ul><li>Chromium</li><li>Firefox</li><li>WebKit</li></ul><p>The Playwright plugin for Claude allows Claude Code to:</p><ul><li>launch browsers</li><li>interact with web pages</li><li>click buttons</li><li>fill forms</li><li>capture screenshots</li><li>run end-to-end tests</li></ul><p>Essentially, Claude can <strong>control a browser just like a human tester would</strong>.</p><h3>Step 1: Install the Playwright Plugin</h3><p>First, install the Playwright plugin from the Claude plugin marketplace.</p><pre>/plugin marketplace add claude-plugins-official/playwright</pre><p>After installation, the plugin will appear inside your Claude plugin directory.</p><p>Typical location:</p><pre>~/.claude/plugins/playwright</pre><h3>Step 2: Install Playwright Dependencies</h3><p>Playwright requires browser binaries to run.</p><p>Install Playwright in your project:</p><pre>npm install -D playwright</pre><p>Then install browser engines:</p><pre>npx playwright install</pre><p>This installs:</p><ul><li>Chromium</li><li>Firefox</li><li>WebKit</li></ul><p>Without this step, the plugin will not be able to launch browsers.</p><h3>Step 3: Use Playwright with Claude</h3><p>Once the plugin is installed, you can simply ask Claude to use Playwright.</p><p>Example prompt:</p><pre>Use Playwright to open https://example.com and summarize the page.</pre><p>Claude will automatically launch a browser and analyze the page.</p><h3>Example: Clicking UI Elements</h3><p>Claude can interact with UI components.</p><p>Example:</p><pre>Use Playwright to open https://example.com<br>and click the login button.</pre><p>Claude will:</p><ol><li>launch the browser</li><li>locate the login button</li><li>click it</li></ol><h3>Example: Filling a Login Form</h3><p>You can also automate form interactions.</p><p>Example:</p><pre>Use Playwright to:</pre><pre>1. open <a href="http://localhost:3000/">http://localhost:3000</a><br>2. click login<br>3. type email test@test.com<br>4. type password 1234<br>5. submit the form</pre><p>Claude will simulate a real user logging into your application.</p><h3>Example: Capturing Screenshots</h3><p>Playwright is also useful for UI inspection.</p><p>Example:</p><pre>Use Playwright to open the homepage and capture a screenshot.</pre><p>This is helpful for:</p><ul><li>UI regression testing</li><li>layout debugging</li><li>design validation</li></ul><h3>Generating Playwright Tests Automatically</h3><p>Claude can also generate Playwright test scripts.</p><p>Example request:</p><pre>Generate a Playwright E2E test for the login feature.</pre><p>Claude might generate something like:</p><pre>import { test, expect } from &#39;@playwright/test&#39;;</pre><pre>test(&#39;login flow&#39;, async ({ page }) =&gt; {<br>  await page.goto(&#39;http://localhost:3000&#39;);<br>  await page.fill(&#39;#email&#39;, &#39;test@test.com&#39;);<br>  await page.fill(&#39;#password&#39;, &#39;1234&#39;);<br>  await page.click(&#39;#login&#39;);<br>  await expect(page).toHaveURL(&#39;/dashboard&#39;);<br>});</pre><p>This can dramatically reduce the time needed to write test suites.</p><h3>Real-World Use Cases</h3><p>Developers commonly use Claude + Playwright for:</p><h3>1. End-to-End Testing</h3><pre>Test login<br>Test checkout flow<br>Test dashboard UI</pre><h3>2. UI Regression Testing</h3><p>Claude can capture screenshots to compare layouts across versions.</p><h3>3. Debugging Frontend Issues</h3><p>Example request:</p><pre>Use Playwright to open my app and detect layout issues.</pre><p>Claude can inspect DOM structure and identify problems.</p><h3>4. Web Scraping</h3><p>Playwright can also extract structured data.</p><p>Example:</p><pre>Use Playwright to extract article titles from this page.</pre><h3>AI-Driven Testing Workflow</h3><p>Advanced users combine Claude with Playwright to create a fully automated testing pipeline.</p><pre>Claude writes code<br>↓<br>Claude generates Playwright tests<br>↓<br>Playwright runs browser tests<br>↓<br>Claude detects failures<br>↓<br>Claude fixes the code</pre><p>This effectively creates an <strong>AI QA pipeline</strong>.</p><h3>Limitations</h3><p>It’s important to note that Playwright is primarily designed for <strong>web applications</strong>.</p><p>It can test:</p><ul><li>web apps</li><li>PWAs</li><li>responsive mobile websites</li></ul><p>But it cannot directly test <strong>native mobile apps</strong> like:</p><ul><li>Android native UI</li><li>iOS Swift apps</li></ul><p>For native mobile testing, tools like Appium are typically used.</p><h3>Final Thoughts</h3><p>AI coding assistants are already improving how developers write code.</p><p>But when combined with browser automation tools like Playwright, they can go even further — helping automate QA, detect UI bugs, and generate reliable end-to-end tests.</p><p>By integrating Claude Code with Playwright, developers can transform their workflow from manual testing to <strong>AI-assisted testing pipelines</strong>.</p><p>And as AI tools continue to evolve, this kind of automation will likely become a standard part of modern development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=611007f88eb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Can Now Test Your iOS App]]></title>
            <link>https://medium.com/@hojunrooneybaek/ai-can-now-test-your-ios-app-4b9b0471dcf0?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b9b0471dcf0</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 05:55:25 GMT</pubDate>
            <atom:updated>2026-03-12T05:55:25.864Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using Claude + iOS Simulator for Autonomous UI Testing</h3><p>Software testing is changing quickly.</p><p>For years, mobile testing required engineers to write long UI test scripts using tools like <strong>XCUITest</strong>, <strong>Appium</strong>, or <strong>Detox</strong>. These tools work well, but they require significant setup and maintenance.</p><p>Now something interesting is happening.</p><p><strong>AI agents can directly interact with iOS apps and run tests autonomously.</strong></p><p>Instead of writing complex test scripts, you can simply tell an AI agent:</p><blockquote><em>“Open the app, log in, and verify the dashboard loads correctly.”</em></blockquote><p>The AI will then control the <strong>iOS Simulator</strong>, inspect the UI, and perform the test automatically.</p><p>In this article, we’ll explore how <strong>Claude + iOS Simulator automation</strong> works and how you can set it up yourself.</p><h3>Why Traditional iOS UI Testing Is Painful</h3><p>Most iOS teams rely on <strong>XCUITest</strong>.</p><p>Example:</p><pre>let app = XCUIApplication()<br>app.launch()</pre><pre>app.textFields[&quot;Email&quot;].tap()<br>app.textFields[&quot;Email&quot;].typeText(&quot;test@example.com&quot;)</pre><pre>app.buttons[&quot;Login&quot;].tap()</pre><p>While this works, it has some problems:</p><ul><li>Writing tests takes time</li><li>Tests often break when UI changes</li><li>Maintenance cost increases as the app grows</li><li>Creating new test cases requires developer effort</li></ul><p>The core issue is that <strong>testing is still script-driven instead of intent-driven.</strong></p><p>You must describe <strong>every action manually</strong>.</p><h3>The AI Testing Model</h3><p>AI agents change the model completely.</p><p>Instead of writing code like this:</p><pre>tap button<br>enter text<br>tap login<br>wait<br>verify dashboard</pre><p>You can simply describe the intention:</p><blockquote><em>“Log in with test credentials and confirm the dashboard appears.”</em></blockquote><p>The AI agent will:</p><ol><li>Launch the app</li><li>Inspect the UI</li><li>Identify input fields</li><li>Enter credentials</li><li>Press the login button</li><li>Verify the next screen</li></ol><p>This works because the agent can read the <strong>Accessibility Tree</strong> of the app.</p><h3>Understanding the Accessibility Tree</h3><p>Every iOS app exposes UI elements through <strong>Accessibility APIs</strong>.</p><p>This allows tools to retrieve a structured view of the UI.</p><p>Example:</p><pre>Button &quot;Login&quot;<br>TextField &quot;Email&quot;<br>TextField &quot;Password&quot;<br>Label &quot;Welcome&quot;</pre><p>Instead of clicking <strong>screen coordinates</strong>, the automation tool can interact with elements by meaning.</p><p>For example:</p><pre>Tap button labeled &quot;Login&quot;</pre><p>This approach is much more stable than coordinate-based automation.</p><h3>The Technology Stack</h3><p>A typical AI-driven iOS automation stack looks like this:</p><pre>AI Agent (Claude)<br>        ↓<br>Automation Skill<br>        ↓<br>idb (iOS Debug Bridge)<br>        ↓<br>iOS Simulator<br>        ↓<br>App Accessibility Tree</pre><p>Each layer plays an important role.</p><p><strong>Claude</strong></p><p>Understands the user instruction and decides what actions to perform.</p><p><strong>Automation skill</strong></p><p>Converts those instructions into automation commands.</p><p><strong>idb</strong></p><p>Acts as the bridge between scripts and the simulator.</p><p><strong>iOS Simulator</strong></p><p>Runs the app and exposes UI elements.</p><h3>Setting Up AI iOS Automation</h3><p>Let’s walk through the setup.</p><h3>1. Install Xcode Command Line Tools</h3><pre>xcode-select --install</pre><h3>2. Install idb</h3><p>idb is a debugging bridge for iOS simulators developed by Meta.</p><p>Install it with Homebrew:</p><pre>brew install facebook/fb/idb-companion<br>pip install fb-idb</pre><p>Verify installation:</p><pre>idb --version</pre><h3>3. Launch the iOS Simulator</h3><pre>open -a Simulator</pre><p>Check available devices:</p><pre>xcrun simctl list devices</pre><h3>4. Inspect the UI</h3><p>You can inspect the current screen’s accessibility tree:</p><pre>idb ui describe-all</pre><p>Example output:</p><pre>Button &quot;Login&quot;<br>TextField &quot;Email&quot;<br>TextField &quot;Password&quot;<br>Button &quot;Sign In&quot;</pre><p>This is the information the AI agent uses to understand the UI.</p><h3>Example: Automating Login</h3><p>You can automate a login flow using Python.</p><pre>import subprocess</pre><pre>def type_email():<br>    subprocess.run([<br>        &quot;idb&quot;,<br>        &quot;ui&quot;,<br>        &quot;text&quot;,<br>        &quot;--label&quot;,<br>        &quot;Email&quot;,<br>        &quot;test@example.com&quot;<br>    ])</pre><pre>def type_password():<br>    subprocess.run([<br>        &quot;idb&quot;,<br>        &quot;ui&quot;,<br>        &quot;text&quot;,<br>        &quot;--label&quot;,<br>        &quot;Password&quot;,<br>        &quot;123456&quot;<br>    ])</pre><pre>def tap_login():<br>    subprocess.run([<br>        &quot;idb&quot;,<br>        &quot;ui&quot;,<br>        &quot;tap&quot;,<br>        &quot;--label&quot;,<br>        &quot;Login&quot;<br>    ])</pre><pre>type_email()<br>type_password()<br>tap_login()</pre><p>This script:</p><ol><li>Finds the email field</li><li>Enters credentials</li><li>Presses the login button</li></ol><p>Because it uses accessibility labels, the automation is <strong>much more stable than coordinate-based testing</strong>.</p><h3>Where AI iOS Testing Becomes Powerful</h3><p>The real power comes when AI agents control this automation layer.</p><p>Instead of writing scripts, you can instruct the AI:</p><blockquote><em>“Test the login flow and take screenshots of every screen.”</em></blockquote><p>The agent can then:</p><ul><li>Inspect the UI</li><li>Navigate through the app</li><li>Detect errors</li><li>Generate test reports</li></ul><p>This turns UI testing into something closer to <strong>natural language programming</strong>.</p><h3>Real Use Cases</h3><p>Teams are starting to use this approach for several workflows.</p><h3>Continuous QA</h3><p>Automatically run tests whenever a new build is created.</p><h3>Regression testing</h3><p>Detect UI changes between versions.</p><h3>Accessibility validation</h3><p>Identify missing accessibility labels.</p><h3>Autonomous QA agents</h3><p>Allow AI to explore the app and detect unexpected issues.</p><h3>The Future of Mobile Testing</h3><p>We are entering a new era where testing is no longer fully manual or script-driven.</p><p>AI agents can now:</p><ul><li>Understand UI structure</li><li>Execute test scenarios</li><li>Detect failures</li><li>Generate reports</li></ul><p>This means the role of developers will shift from <strong>writing test scripts</strong> to <strong>defining testing intent.</strong></p><p>The combination of <strong>AI agents + simulator automation</strong> will likely become a standard part of modern development workflows.</p><h3>Final Thoughts</h3><p>AI-powered automation is not just a small improvement in testing tools.</p><p>It changes the way we think about testing entirely.</p><p>Instead of writing hundreds of fragile scripts, developers can now rely on AI agents that <strong>understand the app and interact with it like a human tester.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b9b0471dcf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Claude Agents Turn One AI into an Entire Development Team]]></title>
            <link>https://medium.com/@hojunrooneybaek/how-claude-agents-turn-one-ai-into-an-entire-development-team-779d1705ac35?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/779d1705ac35</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 05:37:20 GMT</pubDate>
            <atom:updated>2026-03-11T05:37:20.368Z</atom:updated>
            <content:encoded><![CDATA[<p>AI coding assistants are rapidly becoming part of modern development workflows. Tools like Claude can generate code, refactor functions, and debug issues in seconds.</p><p>But most developers still use AI assistants in a <strong>very limited way</strong>:</p><p>One prompt → one answer → one block of code.</p><p>This approach works, but it doesn’t fully leverage what modern AI systems can do.</p><p>Claude provides a feature called <strong>Agents</strong> that allows you to turn a single AI assistant into something much more powerful:</p><p><strong>An AI-powered development team.</strong></p><h3>The Problem with Using a Single AI Assistant</h3><p>Most developers interact with AI tools like this:</p><pre>Developer → AI → Code</pre><p>The AI generates code, and the developer handles everything else:</p><ul><li>architecture decisions</li><li>writing tests</li><li>reviewing code</li><li>checking security</li><li>preparing deployment</li></ul><p>This creates a bottleneck because a single AI response cannot simultaneously play all these roles effectively.</p><p>In real software teams, development doesn’t work this way.</p><p>Instead, it looks more like this:</p><pre>Architect → Developer → Tester → Reviewer → DevOps</pre><p>Each role focuses on a specific responsibility.</p><p>Claude Agents replicate this structure inside the AI workflow.</p><h3>What Are Claude Agents?</h3><p>Claude Agents allow you to define <strong>specialized AI roles</strong> within Claude Code.</p><p>Instead of one assistant doing everything, you can create multiple agents with different responsibilities.</p><p>Example structure:</p><pre>AI Development Team</pre><pre>Architect Agent<br>Backend Engineer Agent<br>Test Engineer Agent<br>Code Reviewer Agent<br>Security Auditor Agent<br>DevOps Agent</pre><p>Each agent has its own instructions and focus area.</p><p>This allows Claude to approach development tasks with <strong>clear role separation</strong>, just like a real engineering team.</p><h3>Why Agents Are Powerful</h3><p>Without agents:</p><pre>Prompt → Claude → Code</pre><p>With agents:</p><pre>Feature Request<br>      ↓<br>Architect Agent designs the system<br>      ↓<br>Backend Agent implements the code<br>      ↓<br>Test Agent generates tests<br>      ↓<br>Review Agent checks for issues<br>      ↓<br>DevOps Agent prepares deployment</pre><p>This structure produces <strong>higher-quality results</strong> because each step focuses on a specific task.</p><h3>7 Useful Claude Agents Developers Use</h3><p>Below are some of the most practical agents developers create.</p><h3>1 Architect Agent</h3><p>This agent focuses on system design.</p><p>Typical responsibilities:</p><ul><li>folder structure</li><li>architecture patterns</li><li>service boundaries</li><li>database design</li></ul><p>Example instruction:</p><pre>You are a senior software architect.<br>Focus on scalable architecture and modular system design.<br>Always propose folder structures and design patterns.</pre><p>Usage example:</p><pre>@architect design the backend architecture for this project</pre><p>This prevents AI from jumping straight into code without a clear design.</p><h3>2 Backend Engineer Agent</h3><p>This agent handles implementation.</p><p>Responsibilities include:</p><ul><li>API development</li><li>database models</li><li>business logic</li></ul><p>Example instruction:</p><pre>You are a senior backend engineer.<br>Write production-ready backend code with clear structure.<br>Prefer maintainable and scalable solutions.</pre><p>Usage:</p><pre>@backend-engineer implement the API endpoint</pre><h3>3 Test Engineer Agent</h3><p>This agent generates tests.</p><p>Responsibilities:</p><ul><li>unit tests</li><li>integration tests</li><li>edge case coverage</li></ul><p>Example instruction:</p><pre>You are a senior test engineer.<br>Write comprehensive tests including edge cases.<br>Prioritize reliability.</pre><p>Usage:</p><pre>@test-engineer create tests for this module</pre><h3>4 Code Reviewer Agent</h3><p>This agent reviews generated code.</p><p>Responsibilities:</p><ul><li>detect bugs</li><li>improve readability</li><li>identify performance issues</li><li>check for security risks</li></ul><p>Example instruction:</p><pre>You are a strict code reviewer.<br>Focus on bugs, security issues, and performance improvements.</pre><p>Usage:</p><pre>@reviewer review this code</pre><h3>5 Refactoring Agent</h3><p>This agent improves existing code without changing behavior.</p><p>Responsibilities:</p><ul><li>simplify complex logic</li><li>improve readability</li><li>modularize code</li></ul><p>Example instruction:</p><pre>You are a refactoring expert.<br>Improve maintainability without changing functionality.</pre><p>Usage:</p><pre>@refactor improve this module</pre><h3>6 Security Auditor Agent</h3><p>Security often gets overlooked in AI-generated code.</p><p>This agent checks for vulnerabilities such as:</p><ul><li>injection attacks</li><li>authentication flaws</li><li>sensitive data leaks</li></ul><p>Example instruction:</p><pre>You are a security auditor.<br>Focus on authentication, authorization, and injection vulnerabilities.</pre><p>Usage:</p><pre>@security-auditor audit this API</pre><h3>7 DevOps Agent</h3><p>This agent focuses on deployment and infrastructure.</p><p>Responsibilities:</p><ul><li>Docker configuration</li><li>CI/CD pipelines</li><li>deployment reliability</li></ul><p>Example instruction:</p><pre>You are a DevOps engineer.<br>Focus on infrastructure reliability and deployment pipelines.</pre><p>Usage:</p><pre>@devops create a docker setup for this project</pre><h3>A Realistic AI Development Workflow</h3><p>When agents are used together, the workflow looks like this:</p><pre>Feature Request<br>      ↓<br>Architect Agent<br>      ↓<br>Backend Engineer Agent<br>      ↓<br>Test Engineer Agent<br>      ↓<br>Code Reviewer Agent<br>      ↓<br>Refactor Agent<br>      ↓<br>DevOps Agent</pre><p>This mirrors the structure of a real engineering team.</p><h3>Combining Agents with Hooks</h3><p>The real power appears when <strong>Agents and Hooks are combined</strong>.</p><p>Example workflow:</p><pre>Backend Agent writes code<br>        ↓<br>Hook automatically runs tests<br>        ↓<br>Test Agent fixes failures<br>        ↓<br>Review Agent checks code quality</pre><p>This creates a <strong>self-improving development loop</strong>.</p><pre>AI writes code<br>↓<br>Tests run automatically<br>↓<br>AI fixes errors<br>↓<br>Code passes validation</pre><h3>Final Thoughts</h3><p>AI coding tools are powerful, but the biggest productivity gains come from <strong>structuring how AI is used</strong>.</p><p>Claude Agents allow developers to transform a single assistant into a coordinated AI team with specialized roles.</p><p>Instead of using AI as a simple code generator, developers can use it as a <strong>complete development workflow system</strong>.</p><p>As AI tools continue evolving, the developers who structure their AI workflows effectively will gain the biggest productivity advantages.</p><p>💡 <strong>Tip</strong></p><p>Many advanced users combine:</p><ul><li>Claude Agents</li><li>Claude Hooks</li><li>automated testing</li></ul><p>to build something very close to an <strong>AI-driven development pipeline</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=779d1705ac35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turn Claude into a Mini CI System with Hooks (A Developer Guide)]]></title>
            <link>https://medium.com/@hojunrooneybaek/turn-claude-into-a-mini-ci-system-with-hooks-a-developer-guide-34151de9aadd?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/34151de9aadd</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 05:05:02 GMT</pubDate>
            <atom:updated>2026-03-11T05:05:02.329Z</atom:updated>
            <content:encoded><![CDATA[<p>AI coding tools are rapidly becoming part of everyday development. Assistants like Claude can generate code, refactor functions, and debug issues within seconds.</p><p>But many developers miss one of the most powerful features available in Claude Code:</p><p><strong>Hooks</strong></p><p>With hooks, you can automate tasks that normally require manual steps — turning Claude into something closer to a <strong>local AI-powered CI pipeline</strong>.</p><p>Instead of just generating code, Claude can automatically:</p><ul><li>run tests</li><li>format code</li><li>check types</li><li>lint files</li><li>validate builds</li></ul><p>This article explains how hooks work and how developers are using them to dramatically improve their workflow.</p><h3>The Problem with AI-Generated Code</h3><p>AI can generate code quickly, but developers still need to validate it.</p><p>Typical workflow:</p><pre>Write code<br>↓<br>Run linter<br>↓<br>Run tests<br>↓<br>Fix errors<br>↓<br>Commit changes</pre><p>When using AI assistants, the process often becomes:</p><pre>Claude writes code<br>↓<br>You manually run tests<br>↓<br>You manually run lint<br>↓<br>You fix errors</pre><p>This slows down the development loop.</p><p>Hooks solve this problem.</p><h3>What Are Claude Hooks?</h3><p>Claude hooks allow you to <strong>trigger commands automatically when certain events happen</strong>.</p><p>Conceptually:</p><pre>Event → Automatic Command</pre><p>Examples of events:</p><ul><li>code generated or modified</li><li>Claude run finished</li><li>file changes detected</li></ul><p>Examples of actions:</p><ul><li>run lint</li><li>run tests</li><li>run formatters</li><li>build containers</li><li>commit code</li></ul><p>With hooks, validation becomes automatic.</p><h3>What the Workflow Looks Like with Hooks</h3><p>Without hooks:</p><pre>Claude generates code<br>↓<br>Developer runs lint<br>↓<br>Developer runs tests<br>↓<br>Developer fixes issues</pre><p>With hooks:</p><pre>Claude generates code<br>↓<br>Hooks run lint + tests<br>↓<br>Errors detected<br>↓<br>Claude fixes issues<br>↓<br>Tests pass automatically</pre><p>You essentially create a <strong>self-correcting AI development loop</strong>.</p><h3>10 Powerful Claude Hooks Developers Use</h3><p>Below are some of the most practical hooks developers use in real projects.</p><h3>1 Automatic Linting</h3><p>Run lint automatically whenever Claude modifies code.</p><pre>/hooks add after-code-change &quot;npm run lint&quot;</pre><p>Benefits:</p><ul><li>prevents messy AI-generated code</li><li>keeps code style consistent</li></ul><h3>2 Automatic Test Execution</h3><p>Probably the most useful hook.</p><pre>/hooks add after-code-change &quot;npm test&quot;</pre><p>Now every AI code change immediately triggers tests.</p><h3>3 Automatic Code Formatting</h3><pre>/hooks add after-code-change &quot;prettier --write .&quot;</pre><p>For Flutter or Dart:</p><pre>/hooks add after-code-change &quot;dart format .&quot;</pre><p>This ensures the entire codebase remains formatted.</p><h3>4 Type Checking (TypeScript)</h3><pre>/hooks add after-code-change &quot;tsc --noEmit&quot;</pre><p>Type errors are detected immediately after code generation.</p><h3>5 Git Auto Commit</h3><p>Automate commits when Claude finishes tasks.</p><pre>/hooks add after-run &quot;git add . &amp;&amp; git commit -m &#39;Claude update&#39;&quot;</pre><p>This creates automatic version history.</p><h3>6 Security Checks</h3><pre>/hooks add after-code-change &quot;npm audit&quot;</pre><p>For Python projects:</p><pre>/hooks add after-code-change &quot;bandit -r .&quot;</pre><p>This helps detect vulnerabilities early.</p><h3>7 Docker Build Verification</h3><p>Backend developers often add this hook.</p><pre>/hooks add after-code-change &quot;docker build .&quot;</pre><p>If the build fails, you know immediately.</p><h3>8 Flutter Static Analysis</h3><p>Flutter developers frequently use this setup.</p><pre>/hooks add after-code-change &quot;flutter analyze&quot;</pre><p>Static analysis runs automatically.</p><h3>9 Claude Activity Logging</h3><p>You can log Claude executions.</p><pre>/hooks add after-run &quot;date &gt;&gt; claude.log&quot;</pre><p>This can be useful for debugging or auditing.</p><h3>10 Automated Test Loops</h3><p>A powerful pattern is running tests automatically.</p><pre>/hooks add after-code-change &quot;pytest&quot;</pre><p>Workflow becomes:</p><pre>Claude writes code<br>↓<br>Tests run<br>↓<br>Failures detected<br>↓<br>Claude fixes the code<br>↓<br>Tests pass</pre><p>This resembles <strong>AI-driven test-driven development</strong>.</p><h3>Example Hook Setup</h3><h3>Node.js Project</h3><pre>/hooks add after-code-change &quot;eslint .&quot;<br>/hooks add after-code-change &quot;prettier --write .&quot;<br>/hooks add after-code-change &quot;tsc --noEmit&quot;<br>/hooks add after-code-change &quot;npm test&quot;</pre><h3>Flutter Project</h3><pre>/hooks add after-code-change &quot;dart format .&quot;<br>/hooks add after-code-change &quot;flutter analyze&quot;<br>/hooks add after-code-change &quot;flutter test&quot;</pre><p>These hooks ensure that any AI-generated code automatically passes formatting, linting, and testing.</p><h3>Claude Hooks as a Local CI Pipeline</h3><p>Once hooks are configured, Claude essentially becomes a <strong>local CI system</strong>.</p><pre>Claude generates code<br>↓<br>Formatting<br>↓<br>Linting<br>↓<br>Type checking<br>↓<br>Testing<br>↓<br>Ready to merge</pre><p>Instead of validating code manually, the validation happens automatically.</p><h3>Final Thoughts</h3><p>AI-assisted coding tools are powerful, but the real productivity gains come from <strong>automation around the AI</strong>.</p><p>Claude Hooks allow developers to build a workflow where AI-generated code is automatically validated, corrected, and improved.</p><p>The result is a faster and safer development process.</p><p>If you’re already using Claude Code, hooks are one of the easiest ways to unlock its full potential.</p><p>💡 <strong>Tip</strong></p><p>Developers who combine:</p><ul><li>hooks</li><li>automated tests</li><li>git automation</li></ul><p>often report <strong>2–5x faster iteration cycles</strong> when working with AI coding assistants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34151de9aadd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Connect GA4 to Google Sheets: 3 Practical Methods (From Easiest to Most Powerful)]]></title>
            <link>https://medium.com/@hojunrooneybaek/how-to-connect-ga4-to-google-sheets-3-practical-methods-from-easiest-to-most-powerful-0d42726e4f1d?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d42726e4f1d</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[spreadsheets]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[ga4]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Thu, 22 Jan 2026 02:13:27 GMT</pubDate>
            <atom:updated>2026-01-22T02:13:27.046Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Analytics 4 (GA4) is one of the most flexible analytics tools available today.</p><p>But many product, data, and growth teams eventually reach the same point:</p><blockquote><strong><em>“I want to pull GA4 data directly into Google Sheets.”</em></strong></blockquote><p>Why?</p><ul><li>lightweight dashboards</li><li>automated daily reports</li><li>KPI monitoring</li><li>cross-team sharing</li><li>easy charting</li><li>“near-BI-tool” behavior without paying for BI tools</li></ul><p>But… GA4 does NOT provide a native Google Sheets connector anymore (The old UA Add-on is deprecated). <br>So how do you actually connect GA4 to Google Sheets?</p><p>In this post, I’ll walk you through <strong>the 3 practical ways</strong> — from easiest to most powerful — with <strong>step-by-step setup instructions</strong>.</p><h3>⭐ Overview — 3 Ways to Connect GA4 → Google Sheets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QptEB5uEUdZ4Fo0YuQI4ug.png" /></figure><p>Let’s go through each method.</p><h3>Method 1. GA4 Data API + Google Apps Script</h3><p>The best method for automation and programmability</p><p>This is the <strong>official</strong> and most scalable way to pull GA4 data into Google Sheets.</p><p>Google Apps Script lets you call GA4’s Data API from JavaScript, write the results directly into the sheet, and even schedule daily automatic refreshes.</p><h4>✅ Step 1. Open Apps Script inside your Google Sheet</h4><ol><li>Open Google Sheets</li><li>Go to <strong>Extensions → Apps Script</strong></li><li>Delete any default code</li></ol><h4>✅ Step 2. Add the required OAuth scopes</h4><p>Open: <strong>Project Settings → Show “appsscript.json” → Edit</strong></p><p>Add:</p><pre>&quot;oauthScopes&quot;: [<br>  &quot;https://www.googleapis.com/auth/spreadsheets&quot;,<br>  &quot;https://www.googleapis.com/auth/script.external_request&quot;,<br>  &quot;https://www.googleapis.com/auth/analytics.readonly&quot;<br>]</pre><p>Save.</p><h4>✅ Step 3. Add GA4 Data API code</h4><p>Replace YOUR_PROPERTY_ID with your GA4 property ID.</p><p>This example pulls event counts for the last 30 days.</p><pre>function fetchGa4EventsLast30Days() {<br>  var propertyId = &#39;YOUR_PROPERTY_ID&#39;;<br>  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&#39;GA4_30D&#39;) <br>              || SpreadsheetApp.getActiveSpreadsheet().insertSheet(&#39;GA4_30D&#39;);<br>  sheet.clear();<br><br>var url = &#39;https://analyticsdata.googleapis.com/v1beta/properties/&#39; + propertyId + &#39;:runReport&#39;;<br>  var requestBody = {<br>    dateRanges: [{ startDate: &#39;30daysAgo&#39;, endDate: &#39;yesterday&#39; }],<br>    dimensions: [{ name: &#39;date&#39; }, { name: &#39;platform&#39; }, { name: &#39;eventName&#39; }],<br>    metrics: [{ name: &#39;eventCount&#39; }]<br>  };<br>  var options = {<br>    method: &#39;post&#39;,<br>    contentType: &#39;application/json&#39;,<br>    payload: JSON.stringify(requestBody),<br>    headers: { Authorization: &#39;Bearer &#39; + ScriptApp.getOAuthToken() }<br>  };<br>  var response = UrlFetchApp.fetch(url, options);<br>  var result = JSON.parse(response.getContentText());<br>  var header = [&#39;date&#39;, &#39;platform&#39;, &#39;eventName&#39;, &#39;eventCount&#39;];<br>  sheet.getRange(1, 1, 1, header.length).setValues([header]);<br>  var rows = result.rows.map(function(r) {<br>    var d = r.dimensionValues[0].value;<br>    var date = d.slice(0,4) + &#39;-&#39; + d.slice(4,6) + &#39;-&#39; + d.slice(6,8);<br>    var platform = r.dimensionValues[1].value;<br>    var eventName = r.dimensionValues[2].value;<br>    var count = Number(r.metricValues[0].value);<br>    return [date, platform, eventName, count];<br>  });<br>  sheet.getRange(2, 1, rows.length, 4).setValues(rows);<br>}</pre><p>Run once → Approve permissions → Data appears in your sheet.</p><h4><strong>✅ Step 4. Grant permissions</strong></h4><p>Apps Script → Google Analytics Data API → Add</p><h4>✅ Step 5. Schedule daily auto-refresh</h4><ol><li>Apps Script → <strong>Triggers</strong></li><li>Add Trigger →<br>- Function: fetchGa4EventsLast30Days<br>- Time-driven<br>- Daily at 9:00 AM</li></ol><p>You now have a fully automated GA4 → Sheets data pipeline.</p><h4>⭐ Pros &amp; Cons</h4><p>✔ Best automation strategy<br>✔ Strong filtering, conditions, platform segmentation<br>✔ No-cost (completely free)<br>✖ Requires scripting<br>✖ Custom event parameters require GA4 custom dimensions</p><h3>Method 2. Looker Studio → Export to Google Sheets</h3><p>The easiest UI-driven approach</p><p>Since Google does <strong>not</strong> provide a GA4 Sheets Add-on, Looker Studio (formerly Data Studio) is the simplest no-code alternative.</p><h4>✅ Step 1. Open Looker Studio</h4><p><a href="https://lookerstudio.google.com/">https://lookerstudio.google.com/</a></p><h4>✅ Step 2. Create a new report → Add Data Source → GA4 property</h4><p>Select:</p><ul><li>Dimensions: date</li><li>Metrics: event count</li><li>Filters: event name, platform, etc.</li></ul><h4>✅ Step 3. Build your chart or table visually</h4><p>No SQL required.</p><h4>✅ Step 4. Export to Google Sheets</h4><p>Looker Studio → <strong>File → Download → CSV<br></strong>Upload to Sheets or Use <strong>Extract Data Source</strong> to automate it.</p><h4>⭐ Pros &amp; Cons</h4><p>✔ Easy, no scripting<br>✔ Perfect for marketing/PM teams<br>✔ Good for visual dashboards<br>✖ Limited customization<br>✖ Manual export unless using Extract source<br>✖ Not scalable for large datasets</p><h3>Method 3. GA4 → BigQuery → Google Sheets (Most Powerful)</h3><p>The enterprise-grade, scalable approach</p><p>If you want to analyze:</p><ul><li>millions of events</li><li>funnel conversions</li><li>cohort analysis</li><li>A/B testing</li><li>notification performance</li><li>user-level data</li></ul><p>…then BigQuery is the best solution.</p><h4>✅ Step 1. Link GA4 to BigQuery</h4><p>GA4 Admin → <strong>BigQuery Linking</strong> → Create a link:</p><ul><li>Choose BigQuery project</li><li>Choose region</li><li>Enable:<br>- <strong>Daily export<br>- Streaming export (near real-time)</strong></li></ul><p>Within 24 hours, GA4 will generate tables:</p><pre>analytics_&lt;property_id&gt;.events_YYYYMMDD<br>analytics_&lt;property_id&gt;.events_*</pre><h4>✅ Step 2. Open Google Sheets → Connect to BigQuery</h4><ol><li>Sheets → <strong>Data → Data connectors → Connect to BigQuery</strong></li><li>Select your GCP project</li><li>Choose the dataset</li><li>Select <strong>“Use custom query”</strong></li></ol><h4>✅ Step 3. Example SQL (last 30 days, iOS/Android, event counts)</h4><pre>SELECT<br>  DATE(TIMESTAMP_MICROS(event_timestamp)) AS event_date,<br>  platform,<br>  event_name,<br>  COUNT(*) AS event_count<br>FROM<br>  `YOUR_PROJECT.analytics_YOUR_PROPERTY_ID.events_*`<br>WHERE<br>  _TABLE_SUFFIX BETWEEN FORMAT_DATE(&#39;%Y%m%d&#39;, DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))<br>                    AND FORMAT_DATE(&#39;%Y%m%d&#39;, CURRENT_DATE())<br>  AND event_name IN (<br>    &#39;notification_open&#39;,<br>    &#39;notification_dismiss&#39;,<br>    &#39;notification_receive&#39;,<br>    &#39;notification_foreground&#39;<br>  )<br>GROUP BY<br>  event_date, platform, event_name<br>ORDER BY<br>  event_date, platform, event_name;</pre><p>Click <strong>Connect</strong> → GA4 data appears in Sheets.</p><h4>✅ Step 4. Enable automatic refresh</h4><p>Sheets → <strong>Data → Scheduled refresh<br></strong>(Refresh every day, hour, etc.)</p><h4>⭐ Pros &amp; Cons</h4><p>✔ Handles massive data<br>✔ SQL gives complete control<br>✔ Access to user properties, event_params, device info<br>✔ Perfect for A/B testing, funnels, growth analytics<br>✖ Requires BigQuery setup<br>✖ May incur small storage/query cost (usually pennies)</p><h4>💰 Cost Comparison</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MH-Yv90WaugSinjk8yux-Q.png" /></figure><p>Most companies pay <strong>zero to just a few dollars per month</strong> for BigQuery.</p><h3>🎯 Final Recommendation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4SOjwZa8LN_Ufl7xf2LAnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d42726e4f1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logging Firebase Analytics for iOS Background Push Notifications in Flutter]]></title>
            <link>https://medium.com/@hojunrooneybaek/logging-firebase-analytics-for-ios-background-push-notifications-in-flutter-55a2e0997417?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/55a2e0997417</guid>
            <category><![CDATA[extention]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 04:20:10 GMT</pubDate>
            <atom:updated>2026-01-19T04:23:57.419Z</atom:updated>
            <content:encoded><![CDATA[<p>A deep dive into tracking background push notification events in iOS using Firebase Analytics, including the challenges and solutions discovered along the way.</p><h3>The Problem</h3><p>When using Firebase Cloud Messaging (FCM) in a Flutter app, Android automatically logs notification_receive events to Firebase Analytics, but <strong>iOS does not log this event for notifications received in background or killed states.</strong></p><pre>✅ Android: notification_receive auto-logged<br>❌ iOS Foreground: notification_foreground auto-logged<br>❌ iOS Background: notification_receive NOT logged<br>✅ iOS Tap: notification_open auto-logged</pre><h3>Understanding iOS Push Notification Flow</h3><p>When a push notification arrives on iOS, it follows this process:</p><pre>1. APNs server receives notification<br>   ↓<br>2. iOS system receives notification<br>   ↓<br>3. NotificationService Extension called<br>   ↓<br>4. Notification displayed to user</pre><p><strong>Key Point:</strong> iOS does not launch the Main App process when the app is in background/killed state. Therefore, Flutter’s FirebaseMessaging.onBackgroundMessage may not be called reliably.</p><h3>What is NotificationService Extension?</h3><p>NotificationService Extension is an iOS 10+ feature that allows you to <strong>modify notification content or perform additional tasks</strong> just before the notification is displayed to the user.</p><p>Common use cases:</p><ul><li>📊 Analytics event logging</li><li>🖼️ Download and attach images</li><li>🔐 Decrypt encrypted messages</li><li>📈 Track campaign data</li></ul><h3>Adding the Extension</h3><h3>1. Create Extension Target in Xcode</h3><pre>Open Runner.xcworkspace in Xcode<br>→ File → New → Target <br>→ Notification Service Extension<br>→ Product Name: NotificationService<br>→ Finish</pre><h3>2. Configure Bundle Identifier</h3><p>The Extension’s Bundle ID must follow the pattern: <strong>Main App Bundle ID + .NotificationService</strong></p><pre>Runner: com.ezcocoa.app.stg<br>Extension: com.ezcocoa.app.stg.NotificationService</pre><p>In Xcode:</p><pre>NotificationService target → Build Settings<br>→ Product Bundle Identifier<br>→ $(PRODUCT_BUNDLE_IDENTIFIER).NotificationService</pre><h3>3. Update Podfile</h3><pre>target &#39;NotificationService&#39; do<br>  use_frameworks!<br>  pod &#39;FirebaseMessaging&#39;<br>end</pre><h3>4. Install Pods</h3><pre>cd ios<br>pod install<br>cd ..</pre><h3>Environment-Specific Firebase Configuration</h3><p>If your project has dev/stg/prod environments, you need to copy the appropriate GoogleService-Info.plist to the Extension.</p><h3>Add Run Script</h3><pre>NotificationService target → Build Phases → + button → New Run Script Phase</pre><p><strong>Script:</strong></p><pre>echo &quot;🔧 Copying GoogleService-Info.plist to Extension&quot;<br><br>case &quot;${CONFIGURATION}&quot; in<br>    *&quot;Debug&quot;* )<br>        cp -r &quot;$SRCROOT/Runner/Firebase/GoogleService-Info-dev.plist&quot; \<br>           &quot;${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.appex/GoogleService-Info.plist&quot;<br>        ;;<br>    *&quot;Profile&quot;* )<br>        cp -r &quot;$SRCROOT/Runner/Firebase/GoogleService-Info-stg.plist&quot; \<br>           &quot;${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.appex/GoogleService-Info.plist&quot;<br>        ;;<br>    *&quot;Release&quot;* )<br>        cp -r &quot;$SRCROOT/Runner/Firebase/GoogleService-Info-prd.plist&quot; \<br>           &quot;${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.appex/GoogleService-Info.plist&quot;<br>        ;;<br>esac</pre><h3>Implementing NotificationService</h3><h3>NotificationService.swift</h3><pre>import UserNotifications<br>import FirebaseMessaging<br>import os.log<br><br>class NotificationService: UNNotificationServiceExtension {<br>    <br>    private let logger = OSLog(subsystem: &quot;com.ezcocoa.app.stg&quot;, <br>                              category: &quot;NotificationService&quot;)<br>    <br>    var contentHandler: ((UNNotificationContent) -&gt; Void)?<br>    var bestAttemptContent: UNMutableNotificationContent?<br>    <br>    override func didReceive(<br>        _ request: UNNotificationRequest,<br>        withContentHandler contentHandler: @escaping (UNNotificationContent) -&gt; Void<br>    ) {<br>        os_log(&quot;🔔 Notification received in background&quot;, <br>               log: logger, type: .default)<br>        <br>        self.contentHandler = contentHandler<br>        bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent<br>        <br>        if let bestAttemptContent = bestAttemptContent {<br>            <br>            // Firebase Messaging processing<br>            // - Download images<br>            // - Track campaigns<br>            // - Analytics events (partial)<br>            Messaging.serviceExtension().populateNotificationContent(<br>                bestAttemptContent,<br>                withContentHandler: contentHandler<br>            )<br>        }<br>    }<br>    <br>    override func serviceExtensionTimeWillExpire() {<br>        os_log(&quot;⏰ Extension time expiring&quot;, log: logger, type: .error)<br>        <br>        if let contentHandler = contentHandler,<br>           let bestAttemptContent = bestAttemptContent {<br>            contentHandler(bestAttemptContent)<br>        }<br>    }<br>}</pre><h3>Critical Discovery: iOS Does Not Auto-Log notification_receive</h3><p>Here’s the important fact I discovered: <strong>According to Firebase official documentation, iOS does NOT automatically collect the </strong><strong>notification_receive event.</strong></p><h3>Firebase Analytics Auto-Collected Events</h3><p><strong>Android:</strong></p><ul><li>✅ notification_receive - Notification received in background/killed state</li><li>✅ notification_foreground - Notification received in foreground</li><li>✅ notification_open - Notification tapped</li><li>✅ notification_dismiss - Notification dismissed</li></ul><p><strong>iOS:</strong></p><ul><li>✅ notification_foreground - Notification received in foreground</li><li>✅ notification_open - Notification tapped</li><li>❌ notification_receive - <strong>NOT supported</strong></li><li>❌ notification_dismiss - NOT supported</li></ul><p>Source: <a href="https://support.google.com/firebase/answer/9234069">Firebase Analytics — Automatically collected events</a></p><h3>Why Doesn’t iOS Support notification_receive?</h3><ol><li><strong>System Constraints:</strong> iOS may not launch the app process when a notification arrives</li><li><strong>Privacy Protection:</strong> Apple restricts tracking to when users actually interact with notifications (notification_open)</li><li><strong>Extension Limitations:</strong> NotificationService Extension has limited runtime (30 seconds, 30MB memory)</li></ol><h3>Solution: Local Tracking with UserDefaults + Sync</h3><p>To track background notifications on iOS, you must <strong>record locally in UserDefaults</strong>, then <strong>sync to Firebase Analytics when the app launches</strong>.</p><h3>1. Configure App Groups</h3><p>Main App and Extension need App Groups to share data.</p><p><strong>Xcode Setup:</strong></p><pre>Runner target → Signing &amp; Capabilities<br>→ + Capability → App Groups<br>→ Add group.com.ezcocoa.app.stg</pre><pre>Configure NotificationService target the same way</pre><h3>2. Auto-Detect Environment-Specific App Group</h3><pre>private var appGroupIdentifier: String {<br>    guard let bundleId = Bundle.main.bundleIdentifier else {<br>        return &quot;group.com.ezcocoa.app&quot;<br>    }<br>    <br>    if bundleId.hasSuffix(&quot;.dev&quot;) {<br>        return &quot;group.com.ezcocoa.app.dev&quot;<br>    } else if bundleId.hasSuffix(&quot;.stg&quot;) {<br>        return &quot;group.com.ezcocoa.app.stg&quot;<br>    } else {<br>        return &quot;group.com.ezcocoa.app&quot;<br>    }<br>}</pre><h3>3. Log in NotificationService</h3><pre>private func logToUserDefaults(request: UNNotificationRequest) {<br>    guard let sharedDefaults = UserDefaults(suiteName: appGroupIdentifier) else {<br>        os_log(&quot;❌ App Group not found&quot;, log: logger, type: .error)<br>        return<br>    }<br>    <br>    // Increment counter<br>    let count = sharedDefaults.integer(forKey: &quot;background_notification_count&quot;)<br>    sharedDefaults.set(count + 1, forKey: &quot;background_notification_count&quot;)<br>    <br>    // Save detailed logs (keep last 50)<br>    var logs = sharedDefaults.array(forKey: &quot;notification_logs&quot;) as? [[String: Any]] ?? []<br>    <br>    logs.append([<br>        &quot;id&quot;: request.identifier,<br>        &quot;title&quot;: request.content.title,<br>        &quot;body&quot;: request.content.body,<br>        &quot;timestamp&quot;: Date().timeIntervalSince1970,<br>        &quot;environment&quot;: appGroupIdentifier<br>    ])<br>    <br>    if logs.count &gt; 50 {<br>        logs.removeFirst(logs.count - 50)<br>    }<br>    <br>    sharedDefaults.set(logs, forKey: &quot;notification_logs&quot;)<br>    sharedDefaults.synchronize()<br>    <br>    os_log(&quot;✅ Logged locally (count: %d)&quot;, log: logger, type: .default, count + 1)<br>}</pre><h3>4. Read Data in Flutter via MethodChannel</h3><p><strong>iOS Native (AppDelegate.swift):</strong></p><pre>import UIKit<br>import Flutter<br><br>@UIApplicationMain<br>@objc class AppDelegate: FlutterAppDelegate {<br>    <br>    override func application(<br>        _ application: UIApplication,<br>        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?<br>    ) -&gt; Bool {<br>        <br>        let controller = window?.rootViewController as! FlutterViewController<br>        let notificationChannel = FlutterMethodChannel(<br>            name: &quot;com.ezcocoa.app/notification_logs&quot;,<br>            binaryMessenger: controller.binaryMessenger<br>        )<br>        <br>        notificationChannel.setMethodCallHandler { [weak self] (call, result) in<br>            self?.handleMethodCall(call: call, result: result)<br>        }<br>        <br>        GeneratedPluginRegistrant.register(with: self)<br>        return super.application(application, didFinishLaunchingWithOptions: launchOptions)<br>    }<br>    <br>    private func handleMethodCall(call: FlutterMethodCall, result: @escaping FlutterResult) {<br>        let appGroupId = getAppGroupIdentifier()<br>        <br>        guard let sharedDefaults = UserDefaults(suiteName: appGroupId) else {<br>            result(FlutterError(code: &quot;APP_GROUP_ERROR&quot;,<br>                              message: &quot;App Group not found&quot;,<br>                              details: nil))<br>            return<br>        }<br>        <br>        switch call.method {<br>        case &quot;getNotificationCount&quot;:<br>            let count = sharedDefaults.integer(forKey: &quot;background_notification_count&quot;)<br>            result(count)<br>            <br>        case &quot;getNotificationLogs&quot;:<br>            let logs = sharedDefaults.array(forKey: &quot;notification_logs&quot;) ?? []<br>            result(logs)<br>            <br>        case &quot;clearNotificationLogs&quot;:<br>            sharedDefaults.set(0, forKey: &quot;background_notification_count&quot;)<br>            sharedDefaults.set([], forKey: &quot;notification_logs&quot;)<br>            sharedDefaults.synchronize()<br>            result(true)<br>            <br>        default:<br>            result(FlutterMethodNotImplemented)<br>        }<br>    }<br>    <br>    private func getAppGroupIdentifier() -&gt; String {<br>        guard let bundleId = Bundle.main.bundleIdentifier else {<br>            return &quot;group.com.ezcocoa.app&quot;<br>        }<br>        <br>        if bundleId.hasSuffix(&quot;.dev&quot;) {<br>            return &quot;group.com.ezcocoa.app.dev&quot;<br>        } else if bundleId.hasSuffix(&quot;.stg&quot;) {<br>            return &quot;group.com.ezcocoa.app.stg&quot;<br>        } else {<br>            return &quot;group.com.ezcocoa.app&quot;<br>        }<br>    }<br>}</pre><p><strong>Flutter (Dart):</strong></p><pre>// lib/services/notification_logger.dart<br>import &#39;package:flutter/services.dart&#39;;<br><br>class NotificationLogger {<br>  static const platform = MethodChannel(&#39;com.ezcocoa.app/notification_logs&#39;);<br>  <br>  static Future&lt;int&gt; getBackgroundNotificationCount() async {<br>    try {<br>      final int count = await platform.invokeMethod(&#39;getNotificationCount&#39;);<br>      return count;<br>    } catch (e) {<br>      print(&#39;Error: $e&#39;);<br>      return 0;<br>    }<br>  }<br>  <br>  static Future&lt;List&lt;Map&lt;String, dynamic&gt;&gt;&gt; getNotificationLogs() async {<br>    try {<br>      final List&lt;dynamic&gt; logs = await platform.invokeMethod(&#39;getNotificationLogs&#39;);<br>      return logs.map((log) =&gt; Map&lt;String, dynamic&gt;.from(log)).toList();<br>    } catch (e) {<br>      print(&#39;Error: $e&#39;);<br>      return [];<br>    }<br>  }<br>  <br>  static Future&lt;bool&gt; clearNotificationLogs() async {<br>    try {<br>      await platform.invokeMethod(&#39;clearNotificationLogs&#39;);<br>      return true;<br>    } catch (e) {<br>      print(&#39;Error: $e&#39;);<br>      return false;<br>    }<br>  }<br>}</pre><h3>5. Sync to Firebase Analytics on App Launch</h3><pre>// lib/main.dart<br>import &#39;package:firebase_analytics/firebase_analytics.dart&#39;;<br>import &#39;services/notification_logger.dart&#39;;<br><br>Future&lt;void&gt; syncBackgroundNotifications() async {<br>  final count = await NotificationLogger.getBackgroundNotificationCount();<br>  <br>  if (count &gt; 0) {<br>    print(&#39;📊 Background notifications received: $count&#39;);<br>    <br>    // Send to Firebase Analytics<br>    await FirebaseAnalytics.instance.logEvent(<br>      name: &#39;background_notifications_received&#39;,<br>      parameters: {<br>        &#39;count&#39;: count,<br>        &#39;synced_at&#39;: DateTime.now().millisecondsSinceEpoch,<br>      },<br>    );<br>    <br>    // Clear logs<br>    await NotificationLogger.clearNotificationLogs();<br>  }<br>}<br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Firebase.initializeApp();<br>  <br>  // Sync background notifications on app launch<br>  await syncBackgroundNotifications();<br>  <br>  runApp(MyApp());<br>}</pre><h3>Add mutable-content to FCM Payload</h3><p><strong>cURL Example:</strong></p><pre>curl -X POST https://fcm.googleapis.com/fcm/send \<br>  -H &quot;Authorization: key=YOUR_SERVER_KEY&quot; \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{<br>    &quot;to&quot;: &quot;DEVICE_FCM_TOKEN&quot;,<br>    &quot;notification&quot;: {<br>      &quot;title&quot;: &quot;Test Notification&quot;,<br>      &quot;body&quot;: &quot;Background test&quot;<br>    },<br>  }&#39;</pre><p><strong>Node.js (Firebase Admin SDK):</strong></p><pre>const message = {<br>  token: deviceToken,<br>  notification: {<br>    title: &#39;Test Notification&#39;,<br>    body: &#39;Background test&#39;<br>  },<br>};<br><br>await admin.messaging().send(message);</pre><h3>Debugging: View Logs in Console.app</h3><p>NotificationService Extension logs don’t appear in the Main App Console because they run in separate processes.</p><h3>Use os_log (Recommended)</h3><pre>import os.log</pre><pre>private let logger = OSLog(subsystem: &quot;com.ezcocoa.app.stg&quot;, <br>                          category: &quot;NotificationService&quot;)</pre><pre>os_log(&quot;🔔 Extension called&quot;, log: logger, type: .default)</pre><h3>View in macOS Console.app</h3><pre>1. Open macOS Console.app<br>2. Select connected iPhone/iPad<br>3. Search: subsystem:com.ezcocoa.app.stg<br>4. Start Streaming<br>5. Send notification and view logs</pre><h3>Troubleshooting</h3><h3>1. Extension Not Included in Build</h3><p><strong>Check:</strong></p><pre>ls build/ios/Profile-STG-iphoneos/Runner.app/PlugIns/<br><br># Should see NotificationService.appex</pre><p><strong>Fix:</strong></p><pre>Runner target → Build Phases<br>→ Embed Foundation Extensions<br>→ Verify NotificationService.appex is added</pre><h3>2. Missing GoogleService-Info.plist</h3><p><strong>Check:</strong></p><pre>ls build/ios/Profile-STG-iphoneos/Runner.app/PlugIns/NotificationService.appex/GoogleService-Info.plist</pre><p><strong>Fix:</strong> Verify Run Script is configured correctly</p><h3>3. Firebase Analytics Import Error</h3><pre>Swift Compiler Error: Unable to find module dependency: &#39;FirebaseAnalytics&#39;</pre><p><strong>Fix:</strong> import FirebaseAnalytics doesn&#39;t work properly in iOS Extensions. Use the UserDefaults approach instead.</p><h3>Build and Deploy</h3><pre># Clean<br>flutter clean<br>cd ios<br>rm -rf Pods Podfile.lock<br>pod install<br>cd ..</pre><pre># Build<br>flutter build ios --profile --flavor stg</pre><pre># Verify<br>ls build/ios/Profile-STG-iphoneos/Runner.app/PlugIns/NotificationService.appex/</pre><h3>Conclusion</h3><p>Logging background push notifications to Analytics on iOS is not as straightforward as on Android. Key takeaways:</p><ol><li><strong>iOS does NOT auto-collect </strong><strong>notification_receive</strong> (confirmed in official documentation)</li><li><strong>NotificationService Extension is required</strong> (for background/killed state handling)</li><li><strong>Use App Groups for data sharing</strong> (Extension → Main App)</li><li><strong>Sync to Firebase Analytics on app launch</strong></li></ol><p>This approach allows you to achieve the same level of notification analytics as Android. Understanding and working around iOS limitations is the key.</p><p><strong>Tags:</strong> #iOS #Flutter #Firebase #FCM #PushNotification #Analytics #NotificationServiceExtension</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55a2e0997417" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Native vs Flutter iOS Build Time: A Comprehensive Comparison]]></title>
            <link>https://medium.com/@hojunrooneybaek/ios-native-vs-flutter-ios-build-time-a-comprehensive-comparison-51f5a95395bf?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/51f5a95395bf</guid>
            <category><![CDATA[build]]></category>
            <category><![CDATA[run]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 00:53:58 GMT</pubDate>
            <atom:updated>2026-01-05T00:53:58.950Z</atom:updated>
            <content:encoded><![CDATA[<h3>🎯 Introduction: Why Build Time Matters</h3><p>One of the biggest factors affecting mobile developer productivity is build time. The waiting time between code modification and seeing results directly impacts development speed.</p><p>Build time isn’t just about waiting — it’s a <strong>critical factor that determines the efficiency of your entire development workflow</strong>.</p><h3>📊 Build Time Comparison: The Numbers</h3><h3>1. Initial Build (Clean Build)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aobhQScUB_zapri-Qt8Vgw.png" /></figure><p><strong>Why Flutter Takes Longer:</strong></p><ul><li>Flutter engine compilation</li><li>Dart code → native binary conversion</li><li>Native code compilation for Flutter plugins</li><li>Additional build steps (flutter build ios → Xcode build)</li></ul><h3>2. Incremental Build</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E27qV6aq3ubpjNKUyrLksQ.png" /></figure><h3>3. Hot Reload/Hot Restart During Development</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QWlY7l5PNCH7yb_c4lb9w.png" /></figure><p><strong>This is where Flutter truly shines.</strong></p><h3>🔍 Understanding the Difference</h3><h3>Domain Model Perspective</h3><p>Let’s use <strong>cooking as an analogy</strong> for the build process:</p><p><strong>iOS Native (Swift/Objective-C):</strong></p><pre>Ingredient prep (source code) <br>  → Cooking (Swift compilation) <br>    → Finished dish (executable)</pre><ul><li>Simple, linear pipeline</li><li>Single optimized toolchain via Xcode</li></ul><p><strong>Flutter iOS:</strong></p><pre>Ingredient prep (Dart code)<br>  → First cooking stage (Dart → intermediate code)<br>    → Flutter engine preparation<br>      → Second cooking stage (native binary generation)<br>        → Xcode build<br>          → Finished dish (executable)</pre><ul><li>Multiple transformation stages</li><li>Two toolchains (Flutter + Xcode)</li><li>Inevitable additional overhead</li></ul><h3>Detailed Build Stage Analysis</h3><p><strong>Flutter iOS Build Process:</strong></p><pre># Stage 1: Flutter Engine Preparation<br>- Flutter SDK loading<br>- Dart VM initialization<br><br># Stage 2: Dart Code Processing<br>- pubspec.yaml dependency resolution<br>- Dart code AOT/JIT compilation<br>- Plugin native code generation<br># Stage 3: Xcode Build<br>- .xcworkspace project loading<br>- CocoaPods dependency processing<br>- Swift/Objective-C compilation<br>- Linking and signing<br># Stage 4: Packaging<br>- Asset bundling<br>- App bundle creation</pre><p><strong>Native iOS only performs stages 3–4.</strong></p><h3>⚡ Practical Optimization Strategies</h3><h3>1. Flutter-Side Optimization</h3><pre>// pubspec.yaml - Remove unnecessary dependencies<br>dependencies:<br>  # Remove heavy packages you don&#39;t use<br>  # flutter_bloc: ^8.0.0  # Remove if unused</pre><pre># Leverage build cache<br>flutter build ios --release --build-number=1 --build-name=1.0.0<br><br># CocoaPods cache<br>pod install --repo-update  # Only when necessary<br>pod install                # Use this normally</pre><h3>2. Xcode Optimization</h3><pre># Podfile<br>platform :ios, &#39;12.0&#39;<br>use_frameworks!<br><br># Enable parallel builds<br>install! &#39;cocoapods&#39;, :deterministic_uuids =&gt; false<br>target &#39;Runner&#39; do<br>  # Use pre-compiled binaries when available<br>end</pre><h3>3. Fastlane Integration for CI/CD Automation</h3><pre># fastlane/Fastfile<br>lane :build_dev do<br>  # Maximize cache usage<br>  cocoapods(<br>    clean_install: false,  # Don&#39;t reinstall if unchanged<br>    repo_update: false<br>  )<br>  <br>  build_app(<br>    workspace: &quot;Runner.xcworkspace&quot;,<br>    scheme: &quot;dev&quot;,<br>    export_method: &quot;development&quot;,<br>    # Incremental build settings<br>    xcargs: &quot;BUILD_LIBRARIES_FOR_DISTRIBUTION=YES&quot;<br>  )<br>end</pre><h3>4. Development Workflow Improvements</h3><pre>// During development, maximize Hot Reload usage<br>// Only full rebuild when:<br>// - Native code modifications<br>// - pubspec.yaml changes<br>// - Plugin additions/removals</pre><h3>5. Additional Build Performance Tips</h3><pre># Clean build artifacts when experiencing issues<br>flutter clean<br>cd ios &amp;&amp; pod deintegrate &amp;&amp; pod install &amp;&amp; cd ..<br><br># Use verbose mode to identify bottlenecks<br>flutter build ios --verbose<br># Profile build time<br>time flutter build ios --release</pre><p><strong>Asset optimization:</strong></p><pre># pubspec.yaml<br>flutter:<br>  assets:<br>    # Only include necessary assets<br>    - assets/images/<br>    # Avoid wildcards that include everything</pre><p><strong>Reduce plugin overhead:</strong></p><pre>// Consider lightweight alternatives<br>// Heavy: google_maps_flutter (500KB+)<br>// Light: flutter_map (200KB)<br><br>// Lazy load expensive plugins<br>import &#39;package:heavy_plugin/heavy_plugin.dart&#39; deferred as heavy;<br>Future&lt;void&gt; useHeavyFeature() async {<br>  await heavy.loadLibrary();<br>  heavy.doSomething();<br>}</pre><h3>📈 Real-World Measurements</h3><p><strong>Environment:</strong></p><ul><li>MacBook Pro M1 Pro</li><li>Flutter 3.29.3</li><li>Xcode 15.x</li><li>Medium-sized project (20+ plugins)</li></ul><p><strong>Measurement Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dvDfDwe7Mti860t6x1C6_Q.png" /></figure><p><strong>Daily Time Analysis:</strong></p><pre>Typical Development Day (100 iterations):</pre><pre>iOS Native:<br>- 100 rebuilds × 30s average = 50 minutes waiting</pre><pre>Flutter:<br>- 95 Hot Reloads × 1s = 95 seconds<br>- 5 Full rebuilds × 90s = 450 seconds<br>- Total: ~9 minutes waiting</pre><pre>Time saved: 41 minutes per day</pre><p><strong>Analysis:</strong></p><ul><li>Initial build vs Native: 2–3x slower</li><li>But with Hot Reload, <strong>actual development time is significantly reduced</strong></li></ul><h3>🎯 The Hidden Costs: Beyond Raw Numbers</h3><h3>1. Context Switching</h3><p>The psychological impact of build times is often underestimated:</p><p><strong>30-second builds (Native):</strong></p><ul><li>Too long to wait and watch</li><li>Too short to switch tasks effectively</li><li>Result: Checking phone, losing focus</li></ul><p><strong>1-second Hot Reload (Flutter):</strong></p><ul><li>See changes instantly</li><li>Stay in flow state</li><li>Maintain mental context</li></ul><p><strong>Think of it as:</strong> Native builds are like traffic lights that are just long enough to be annoying but too short to do anything productive. Flutter’s Hot Reload is like having a green light all the way.</p><h3>2. Learning Curve Impact</h3><p><strong>Native iOS:</strong></p><ul><li>Longer feedback loop slows learning</li><li>Experimenting with UI is tedious</li><li>Junior developers iterate less</li></ul><p><strong>Flutter:</strong></p><ul><li>Rapid experimentation encourages learning</li><li>UI changes visible immediately</li><li>Faster skill development</li></ul><h3>3. Team Collaboration</h3><p><strong>Design-Developer Iteration:</strong></p><pre>Native Workflow:<br>Designer: &quot;Can you move this button 10px down?&quot;<br>Developer: *waits 30s* &quot;How&#39;s this?&quot;<br>Designer: &quot;Perfect, now 5px up&quot;<br>Developer: *waits 30s again*<br>= Multiple minutes per small change<br><br>Flutter Workflow:<br>Designer: &quot;Can you move this button 10px down?&quot;<br>Developer: *Hot Reload 1s* &quot;How&#39;s this?&quot;<br>Designer: &quot;Perfect, now 5px up&quot;<br>Developer: *Hot Reload 1s again*<br>= Seconds per change</pre><h3>💡 Conclusion: Thinking Backwards from the Goal</h3><h3>Calculating from the End Goal</h3><p><strong>Goal: 100 code modification-verification cycles per day</strong></p><p><strong>iOS Native Approach:</strong></p><ul><li>Average 30s build wait each time</li><li>Total wait time: 50min/day</li></ul><p><strong>Flutter Approach:</strong></p><ul><li>95 times: Hot Reload (1s) = 95s</li><li>5 times: Full build (90s) = 450s</li><li>Total wait time: ~9min/day</li></ul><p><strong>Flutter is actually 5x faster in practice.</strong></p><h3>When is Native Better?</h3><ol><li><strong>Extremely complex native features</strong> (advanced camera controls, AR, etc.)</li><li><strong>Latest iOS-only features without Flutter plugin support</strong></li><li><strong>When app size is critically important</strong> (Flutter adds ~4–5MB overhead)</li><li><strong>Teams already deeply invested in Swift/SwiftUI ecosystem</strong></li><li><strong>Projects requiring maximum performance</strong> (though Flutter is close)</li></ol><h3>Why Choose Flutter</h3><p><strong>Primary Advantages:</strong></p><ol><li><strong>Development productivity</strong> (Hot Reload saves hours daily)</li><li><strong>Cross-platform</strong> (iOS + Android with single codebase)</li><li><strong>Rich ecosystem</strong> (pub.dev has 45,000+ packages)</li><li><strong>Mature tooling</strong> (DevTools, testing, deployment)</li><li><strong>Declarative UI</strong> (easier to reason about than UIKit)</li></ol><p><strong>Trade-offs to Accept:</strong></p><ol><li>Slower initial builds (2–3x)</li><li>Larger app size (~4–5MB framework overhead)</li><li>Occasional platform-specific issues</li><li>Extra layer of abstraction</li></ol><h3>🎬 Practical Decision Framework</h3><h3>Use Flutter When:</h3><p>✅ Building for both iOS and Android<br> ✅ Team knows Dart or willing to learn<br> ✅ Rapid iteration is critical<br> ✅ UI-heavy application<br> ✅ Standard platform features are sufficient</p><h3>Use Native When:</h3><p>✅ iOS-only application with no Android plans<br> ✅ Team deeply experienced in Swift/SwiftUI<br> ✅ Requiring cutting-edge iOS features day-one<br> ✅ App size is critical constraint<br> ✅ Maximum performance is non-negotiable</p><h3>Hybrid Approach:</h3><p>Consider <strong>Flutter with Platform Channels</strong> for best of both:</p><pre>// Most of app in Flutter<br>class MyApp extends StatelessWidget {<br>  // ... Flutter UI code<br>}<br><br>// Performance-critical features in native<br>class NativeFeature {<br>  static const platform = MethodChannel(&#39;com.example/native&#39;);<br>  <br>  Future&lt;void&gt; callNativeCode() async {<br>    await platform.invokeMethod(&#39;performanceMethod&#39;);<br>  }<br>}</pre><h3>📊 Real-World Case Studies</h3><h3>Case Study 1: Small Startup</h3><p><strong>Context:</strong> 3-person team, MVP for iOS and Android</p><p><strong>Native Approach:</strong></p><ul><li>Need 2 developers (1 iOS, 1 Android)</li><li>6 months development time</li><li>Maintain two codebases</li></ul><p><strong>Flutter Approach:</strong></p><ul><li>1 developer handles both platforms</li><li>3–4 months development time</li><li>Single codebase</li></ul><p><strong>Verdict:</strong> Flutter saved 40% development time and cost</p><h3>Case Study 2: Enterprise App</h3><p><strong>Context:</strong> Complex business app, 100+ screens</p><p><strong>Build Time Impact:</strong></p><ul><li>Native: 10min full builds, 30s incremental</li><li>Flutter: 15min full builds, 1s Hot Reload</li></ul><p><strong>Over 6 months:</strong></p><ul><li>Native: ~125 hours waiting for builds</li><li>Flutter: ~30 hours waiting for builds</li></ul><p><strong>Verdict:</strong> Flutter saved ~95 hours per developer</p><h3>Case Study 3: Game-like App</h3><p><strong>Context:</strong> High-performance graphics, 60fps animations</p><p><strong>Native Approach:</strong></p><ul><li>Direct Metal/Core Animation access</li><li>Optimized for iOS hardware</li><li>Smooth performance</li></ul><p><strong>Flutter Approach:</strong></p><ul><li>Skia rendering engine</li><li>Good but not perfect performance</li><li>Occasional jank on complex animations</li></ul><p><strong>Verdict:</strong> Native chosen for maximum performance</p><h3>🔚 Final Thoughts</h3><p>Build time is about <strong>developer happiness and productivity</strong>, not just numbers on a benchmark.</p><p>Flutter’s longer initial builds are a real trade-off, but Hot Reload transforms the development experience. The question isn’t “which builds faster?” but “which lets you work better?”</p><p><strong>The math is clear:</strong> If you value your development time, Flutter’s Hot Reload saves hours every single day compared to Native’s rebuild cycle. Those saved hours compound over weeks and months into significantly faster product delivery.</p><p>However, Flutter isn’t a silver bullet. Native iOS development still has its place for iOS-specific apps requiring maximum performance or cutting-edge platform features.</p><p><strong>Choose based on your priorities:</strong></p><ul><li>Need speed to market? → Flutter</li><li>Need maximum iOS integration? → Native</li><li>Need both iOS and Android? → Flutter</li><li>Need that extra 5% performance? → Native</li></ul><p>The best tool is the one that helps your team ship great products efficiently.</p><h3>📚 Additional Resources</h3><ul><li><a href="https://docs.flutter.dev/perf/best-practices">Flutter Performance Best Practices</a></li><li><a href="https://developer.apple.com/documentation/xcode/improving-build-efficiency">Xcode Build Time Optimization</a></li><li><a href="https://docs.fastlane.tools/">Fastlane for Flutter</a></li><li><a href="https://flutter.dev/docs/resources/faq#what-kind-of-performance-can-i-expect">Flutter vs Native Performance</a></li><li><a href="https://guides.cocoapods.org/using/performance.html">CocoaPods Optimization Guide</a></li></ul><p><strong>Have you experienced different build time patterns?</strong> Share your measurements and optimizations in the comments below! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51f5a95395bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Flutter Environment Variables: Secure and Automated Configuration Management]]></title>
            <link>https://medium.com/@hojunrooneybaek/the-ultimate-guide-to-flutter-environment-variables-secure-and-automated-configuration-management-f9aa7b822ece?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9aa7b822ece</guid>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 09:16:23 GMT</pubDate>
            <atom:updated>2025-12-22T09:16:23.786Z</atom:updated>
            <content:encoded><![CDATA[<h3>TL;DR</h3><p>A comprehensive guide to securely managing development/staging/production environments in Flutter apps, keeping sensitive information out of Git while maintaining full build automation.</p><p><strong>Key Features:</strong></p><ul><li>✅ Sensitive information never committed to Git</li><li>✅ Support for both Android/iOS native and Flutter</li><li>✅ Automatic environment variable injection at build time</li><li>✅ Single .env file manages all platforms</li></ul><h3>The Problem</h3><p>When developing Flutter apps, you inevitably face this dilemma:</p><pre>// ❌ We know hardcoding is wrong, but...<br>const String apiKey = &quot;super_secret_key_12345&quot;;<br>const String baseUrl = &quot;https://api.myapp.com&quot;;</pre><p><strong>Why is this problematic?</strong></p><ol><li><strong>Security Risk</strong>: API keys exposed directly in Git repository</li><li><strong>No Environment Separation</strong>: Difficult to distinguish Dev/Staging/Prod</li><li><strong>Team Collaboration Issues</strong>: Each developer needs different configurations</li><li><strong>CI/CD Integration Complexity</strong>: Challenging to inject environment variables in automated builds</li></ol><p>Most solutions fix one problem but create others:</p><ul><li>flutter_dotenv: Runtime loading causes performance overhead, files included in app</li><li>Hardcoded configs: Security vulnerabilities, inconvenient environment switching</li><li>Firebase Remote Config: Network dependency, initial loading issues</li></ul><p><strong>What we want:</strong></p><ul><li>Sensitive information must stay out of Git</li><li>Environment determined at build time</li><li>Accessible from native code</li><li>Automation-friendly</li></ul><h3>Solution Overview</h3><p>Our approach is straightforward:</p><pre>.env files (excluded from Git)<br>    ↓<br>Build script conversion<br>    ↓<br>Android: BuildConfig / iOS: xcconfig + Info.plist<br>    ↓<br>Method Channel<br>    ↓<br>Flutter (Dart)</pre><p><strong>Core Concept:</strong></p><ol><li>Define environment variables in .env files (Git ignored)</li><li>Automatically convert to native configuration files at build time</li><li>Accessible from both native and Flutter</li></ol><h3>Implementation Steps</h3><h3>Step 1: Project Structure</h3><pre>project/<br>├── .env.dev              # Excluded from Git<br>├── .env.staging          # Excluded from Git<br>├── .env.prod             # Excluded from Git<br>├── .env.example          # Included in Git (template)<br>├── scripts/<br>│   └── generate_env_config.sh<br>├── android/<br>│   ├── gradle-dev.properties      # Auto-generated<br>│   ├── gradle-staging.properties  # Auto-generated<br>│   └── gradle-prod.properties     # Auto-generated<br>├── ios/<br>│   ├── Flutter/Environment/<br>│   │   ├── Debug.xcconfig         # Auto-generated<br>│   │   ├── Profile.xcconfig       # Auto-generated<br>│   │   └── Release.xcconfig       # Auto-generated<br>│   └── scripts/<br>│       └── setup_xcconfig.sh      # Auto-generated<br>└── lib/<br>    └── core/<br>        └── env_config.dart        # Auto-generated</pre><h3>Step 2: Create Environment Files</h3><p><strong>.env.dev:</strong></p><pre>API_KEY=dev_api_key_12345<br>BASE_URL=https://dev-api.myapp.com<br>FIREBASE_PROJECT_ID=myapp-dev<br>GA_TRACKING_ID=G-DEV123456<br>APP_NAME=MyApp Dev</pre><p><strong>.env.staging:</strong></p><pre>API_KEY=staging_api_key_67890<br>BASE_URL=https://staging-api.myapp.com<br>FIREBASE_PROJECT_ID=myapp-staging<br>GA_TRACKING_ID=G-STAGING123456<br>APP_NAME=MyApp Staging</pre><p><strong>.env.prod:</strong></p><pre>API_KEY=prod_api_key_abcde<br>BASE_URL=https://api.myapp.com<br>FIREBASE_PROJECT_ID=myapp-prod<br>GA_TRACKING_ID=G-PROD123456<br>APP_NAME=MyApp</pre><p><strong>.env.example (included in Git):</strong></p><pre>API_KEY=your_api_key_here<br>BASE_URL=https://api.example.com<br>FIREBASE_PROJECT_ID=your-project-id<br>GA_TRACKING_ID=G-XXXXXXXXXX<br>APP_NAME=Your App Name</pre><h3>Step 3: Create Automation Script</h3><p><strong>scripts/generate_env_config.sh:</strong></p><pre>#!/bin/bash<br><br># Color definitions<br>RED=&#39;\033[0;31m&#39;<br>GREEN=&#39;\033[0;32m&#39;<br>YELLOW=&#39;\033[1;33m&#39;<br>NC=&#39;\033[0m&#39;<br>PROJECT_ROOT=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)/..&quot; &amp;&amp; pwd)&quot;<br>ENVIRONMENTS=(&quot;dev&quot; &quot;staging&quot; &quot;prod&quot;)<br>echo -e &quot;${GREEN}🚀 Starting environment configuration generation...${NC}\n&quot;<br># Generate Android gradle.properties<br>generate_android_gradle_properties() {<br>    local env=$1<br>    local env_file=&quot;${PROJECT_ROOT}/.env.${env}&quot;<br>    local output_file=&quot;${PROJECT_ROOT}/android/gradle-${env}.properties&quot;<br>    <br>    if [ ! -f &quot;$env_file&quot; ]; then<br>        echo -e &quot;${RED}❌ Cannot find ${env_file}${NC}&quot;<br>        return 1<br>    fi<br>    <br>    echo -e &quot;${YELLOW}📱 Generating Android gradle-${env}.properties...${NC}&quot;<br>    <br>    cat &gt; &quot;$output_file&quot; &lt;&lt; &#39;EOF&#39;<br># Auto-generated file - DO NOT EDIT MANUALLY<br>EOF<br>    <br>    while IFS=&#39;=&#39; read -r key value || [ -n &quot;$key&quot; ]; do<br>        [[ &quot;$key&quot; =~ ^#.*$ ]] &amp;&amp; continue<br>        [[ -z &quot;$key&quot; ]] &amp;&amp; continue<br>        <br>        key=$(echo &quot;$key&quot; | xargs)<br>        value=$(echo &quot;$value&quot; | xargs)<br>        value=&quot;${value%\&quot;}&quot;<br>        value=&quot;${value#\&quot;}&quot;<br>        <br>        echo &quot;${key}=${value}&quot; &gt;&gt; &quot;$output_file&quot;<br>    done &lt; &quot;$env_file&quot;<br>    <br>    echo -e &quot;${GREEN}✅ ${output_file} generated${NC}\n&quot;<br>}<br># Generate iOS xcconfig files<br>generate_ios_env_xcconfig() {<br>    local env=$1<br>    local env_file=&quot;${PROJECT_ROOT}/.env.${env}&quot;<br>    <br>    local build_config<br>    case &quot;$env&quot; in<br>        dev) build_config=&quot;Debug&quot; ;;<br>        staging) build_config=&quot;Profile&quot; ;;<br>        prod) build_config=&quot;Release&quot; ;;<br>        *) echo -e &quot;${RED}❌ Unknown environment: ${env}${NC}&quot;; return 1 ;;<br>    esac<br>    <br>    local env_dir=&quot;${PROJECT_ROOT}/ios/Flutter/Environment&quot;<br>    mkdir -p &quot;$env_dir&quot;<br>    <br>    local output_file=&quot;${env_dir}/${build_config}.xcconfig&quot;<br>    <br>    if [ ! -f &quot;$env_file&quot; ]; then<br>        echo -e &quot;${RED}❌ Cannot find ${env_file}${NC}&quot;<br>        return 1<br>    fi<br>    <br>    echo -e &quot;${YELLOW}🍎 Generating iOS ${build_config}.xcconfig...${NC}&quot;<br>    <br>    cat &gt; &quot;$output_file&quot; &lt;&lt; EOF<br>// Auto-generated file - DO NOT EDIT MANUALLY<br>// Generated from .env.${env}<br>EOF<br>    <br>    local var_count=0<br>    while IFS=&#39;=&#39; read -r key value || [ -n &quot;$key&quot; ]; do<br>        [[ &quot;$key&quot; =~ ^#.*$ ]] &amp;&amp; continue<br>        [[ -z &quot;$key&quot; ]] &amp;&amp; continue<br>        <br>        key=$(echo &quot;$key&quot; | xargs)<br>        value=$(echo &quot;$value&quot; | xargs)<br>        value=&quot;${value%\&quot;}&quot;<br>        value=&quot;${value#\&quot;}&quot;<br>        <br>        # Convert :// to :/$()/  to avoid xcconfig comment issue<br>        if [[ &quot;$value&quot; =~ :// ]]; then<br>            value=$(echo &quot;$value&quot; | sed &#39;s|://|:/$()/|g&#39;)<br>        fi<br>        <br>        echo &quot;${key} = ${value}&quot; &gt;&gt; &quot;$output_file&quot;<br>        ((var_count++))<br>    done &lt; &quot;$env_file&quot;<br>    <br>    cat &gt;&gt; &quot;$output_file&quot; &lt;&lt; EOF<br>// Environment Metadata<br>ENVIRONMENT_NAME = ${env}<br>BUILD_CONFIGURATION = ${build_config}<br>EOF<br>    <br>    echo -e &quot;${GREEN}✅ ${output_file} generated (${var_count} variables)${NC}\n&quot;<br>}<br># Generate iOS prebuild script<br>generate_ios_prebuild_script() {<br>    local script_file=&quot;${PROJECT_ROOT}/ios/scripts/setup_xcconfig.sh&quot;<br>    mkdir -p &quot;${PROJECT_ROOT}/ios/scripts&quot;<br>    <br>    echo -e &quot;${YELLOW}🔧 Generating iOS build script...${NC}&quot;<br>    <br>    cat &gt; &quot;$script_file&quot; &lt;&lt; &#39;EOF&#39;<br>#!/bin/bash<br># Add Environment xcconfig include to Flutter-generated xcconfig<br>PROJECT_DIR=&quot;${PROJECT_DIR:-$(cd &quot;$(dirname &quot;$0&quot;)/..&quot; &amp;&amp; pwd)}&quot;<br>FLUTTER_DIR=&quot;${PROJECT_DIR}/Flutter&quot;<br>CONFIGS=(&quot;Debug&quot; &quot;Profile&quot; &quot;Release&quot;)<br>echo &quot;🔧 Adding Environment include to xcconfig files...&quot;<br>for config in &quot;${CONFIGS[@]}&quot;; do<br>    XCCONFIG_FILE=&quot;${FLUTTER_DIR}/${config}.xcconfig&quot;<br>    ENV_XCCONFIG=&quot;Environment/${config}.xcconfig&quot;<br>    INCLUDE_LINE=&quot;#include \&quot;${ENV_XCCONFIG}\&quot;&quot;<br>    <br>    [ ! -f &quot;$XCCONFIG_FILE&quot; ] &amp;&amp; continue<br>    [ ! -f &quot;${FLUTTER_DIR}/${ENV_XCCONFIG}&quot; ] &amp;&amp; continue<br>    <br>    if grep -q &quot;^#include \&quot;${ENV_XCCONFIG}\&quot;&quot; &quot;$XCCONFIG_FILE&quot;; then<br>        echo &quot;✅ ${config}.xcconfig: Already configured&quot;<br>        continue<br>    fi<br>    <br>    # macOS/Linux compatible<br>    if [[ &quot;$OSTYPE&quot; == &quot;darwin&quot;* ]]; then<br>        sed -i &#39;&#39; &quot;/^#include \&quot;Generated.xcconfig\&quot;/a\\<br>${INCLUDE_LINE}<br>&quot; &quot;$XCCONFIG_FILE&quot;<br>    else<br>        sed -i &quot;/^#include \&quot;Generated.xcconfig\&quot;/a ${INCLUDE_LINE}&quot; &quot;$XCCONFIG_FILE&quot;<br>    fi<br>    <br>    echo &quot;✅ ${config}.xcconfig: Include added&quot;<br>done<br>echo &quot;✅ xcconfig setup complete&quot;<br>EOF<br>    <br>    chmod +x &quot;$script_file&quot;<br>    echo -e &quot;${GREEN}✅ ${script_file} generated${NC}\n&quot;<br>}<br># Generate Android build.gradle config<br>generate_android_build_config() {<br>    local output_file=&quot;${PROJECT_ROOT}/android/app/env_config.gradle&quot;<br>    <br>    echo -e &quot;${YELLOW}📱 Generating Android env_config.gradle...${NC}&quot;<br>    <br>    cat &gt; &quot;$output_file&quot; &lt;&lt; &#39;EOF&#39;<br>android {<br>    flavorDimensions &quot;environment&quot;<br>    <br>    productFlavors {<br>        dev {<br>            dimension &quot;environment&quot;<br>            applicationIdSuffix &quot;.dev&quot;<br>            <br>            def props = new Properties()<br>            file(&quot;$rootDir/gradle-dev.properties&quot;).withInputStream { props.load(it) }<br>            <br>            resValue &quot;string&quot;, &quot;app_name&quot;, props.getProperty(&#39;APP_NAME&#39;, &#39;App Dev&#39;)<br>            buildConfigField &quot;String&quot;, &quot;API_KEY&quot;, &quot;\&quot;${props.getProperty(&#39;API_KEY&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;${props.getProperty(&#39;BASE_URL&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;FIREBASE_PROJECT_ID&quot;, &quot;\&quot;${props.getProperty(&#39;FIREBASE_PROJECT_ID&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;ENVIRONMENT_NAME&quot;, &quot;\&quot;dev\&quot;&quot;<br>        }<br>        <br>        staging {<br>            dimension &quot;environment&quot;<br>            applicationIdSuffix &quot;.staging&quot;<br>            <br>            def props = new Properties()<br>            file(&quot;$rootDir/gradle-staging.properties&quot;).withInputStream { props.load(it) }<br>            <br>            resValue &quot;string&quot;, &quot;app_name&quot;, props.getProperty(&#39;APP_NAME&#39;, &#39;App Staging&#39;)<br>            buildConfigField &quot;String&quot;, &quot;API_KEY&quot;, &quot;\&quot;${props.getProperty(&#39;API_KEY&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;${props.getProperty(&#39;BASE_URL&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;FIREBASE_PROJECT_ID&quot;, &quot;\&quot;${props.getProperty(&#39;FIREBASE_PROJECT_ID&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;ENVIRONMENT_NAME&quot;, &quot;\&quot;staging\&quot;&quot;<br>        }<br>        <br>        prod {<br>            dimension &quot;environment&quot;<br>            <br>            def props = new Properties()<br>            file(&quot;$rootDir/gradle-prod.properties&quot;).withInputStream { props.load(it) }<br>            <br>            resValue &quot;string&quot;, &quot;app_name&quot;, props.getProperty(&#39;APP_NAME&#39;, &#39;App&#39;)<br>            buildConfigField &quot;String&quot;, &quot;API_KEY&quot;, &quot;\&quot;${props.getProperty(&#39;API_KEY&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;${props.getProperty(&#39;BASE_URL&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;FIREBASE_PROJECT_ID&quot;, &quot;\&quot;${props.getProperty(&#39;FIREBASE_PROJECT_ID&#39;, &#39;&#39;)}\&quot;&quot;<br>            buildConfigField &quot;String&quot;, &quot;ENVIRONMENT_NAME&quot;, &quot;\&quot;prod\&quot;&quot;<br>        }<br>    }<br>}<br>EOF<br>    <br>    echo -e &quot;${GREEN}✅ ${output_file} generated${NC}\n&quot;<br>}<br># Generate Flutter Dart environment config<br>generate_dart_env_config() {<br>    local dart_file=&quot;${PROJECT_ROOT}/lib/core/env_config.dart&quot;<br>    mkdir -p &quot;${PROJECT_ROOT}/lib/core&quot;<br>    <br>    echo -e &quot;${YELLOW}🎯 Generating Dart environment config...${NC}&quot;<br>    <br>    cat &gt; &quot;$dart_file&quot; &lt;&lt; &#39;EOF&#39;<br>import &#39;dart:io&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br>class EnvConfig {<br>  static const _channel = MethodChannel(&#39;com.myapp/env_config&#39;);<br>  static Map&lt;String, String&gt;? _cache;<br>  <br>  /// Load all environment variables<br>  static Future&lt;Map&lt;String, String&gt;&gt; getAll() async {<br>    if (_cache != null) return _cache!;<br>    <br>    try {<br>      final result = await _channel.invokeMethod&lt;Map&gt;(&#39;getAllEnv&#39;);<br>      _cache = Map&lt;String, String&gt;.from(result ?? {});<br>      return _cache!;<br>    } catch (e) {<br>      print(&#39;Failed to load environment variables: $e&#39;);<br>      return {};<br>    }<br>  }<br>  <br>  /// Get individual environment variable<br>  static Future&lt;String&gt; get(String key) async {<br>    final all = await getAll();<br>    return all[key] ?? &#39;&#39;;<br>  }<br>  <br>  /// Commonly used environment variables (async)<br>  static Future&lt;String&gt; get apiKey =&gt; get(&#39;API_KEY&#39;);<br>  static Future&lt;String&gt; get baseURL =&gt; get(&#39;BASE_URL&#39;);<br>  static Future&lt;String&gt; get environmentName =&gt; get(&#39;ENVIRONMENT_NAME&#39;);<br>  <br>  /// Synchronous version (use after calling getAll())<br>  static String getSync(String key) =&gt; _cache?[key] ?? &#39;&#39;;<br>  <br>  static String get apiKeySync =&gt; getSync(&#39;API_KEY&#39;);<br>  static String get baseURLSync =&gt; getSync(&#39;BASE_URL&#39;);<br>  static String get environmentNameSync =&gt; getSync(&#39;ENVIRONMENT_NAME&#39;);<br>}<br>EOF<br>    <br>    echo -e &quot;${GREEN}✅ ${dart_file} generated${NC}\n&quot;<br>}<br># Update .gitignore<br>update_gitignore() {<br>    local gitignore=&quot;${PROJECT_ROOT}/.gitignore&quot;<br>    <br>    if ! grep -q &quot;^\.env\.&quot; &quot;$gitignore&quot; 2&gt;/dev/null; then<br>        cat &gt;&gt; &quot;$gitignore&quot; &lt;&lt; &#39;EOF&#39;<br># Environment files (DO NOT COMMIT)<br>.env.dev<br>.env.staging<br>.env.prod<br># Android generated<br>android/gradle-*.properties<br># iOS generated<br>ios/Flutter/Environment/<br>ios/scripts/setup_xcconfig.sh<br>EOF<br>    fi<br>}<br># Main execution<br>main() {<br>    for env in &quot;${ENVIRONMENTS[@]}&quot;; do<br>        generate_android_gradle_properties &quot;$env&quot;<br>        generate_ios_env_xcconfig &quot;$env&quot;<br>    done<br>    <br>    generate_android_build_config<br>    generate_ios_prebuild_script<br>    generate_dart_env_config<br>    update_gitignore<br>    <br>    echo -e &quot;${GREEN}🎉 All environment configuration files generated!${NC}\n&quot;<br>}<br><br>main</pre><h3>Step 4: Android Native Setup</h3><p><strong>Add to android/app/build.gradle:</strong></p><pre>apply from: &quot;$rootDir/app/env_config.gradle&quot;</pre><p><strong>android/app/src/main/kotlin/…/EnvConfigPlugin.kt:</strong></p><pre>package com.myapp<br><br>import io.flutter.embedding.engine.FlutterEngine<br>import io.flutter.plugin.common.MethodChannel<br>class EnvConfigPlugin {<br>    companion object {<br>        private const val CHANNEL = &quot;com.myapp/env_config&quot;<br>        <br>        fun registerWith(flutterEngine: FlutterEngine) {<br>            val channel = MethodChannel(<br>                flutterEngine.dartExecutor.binaryMessenger,<br>                CHANNEL<br>            )<br>            <br>            channel.setMethodCallHandler { call, result -&gt;<br>                when (call.method) {<br>                    &quot;getAllEnv&quot; -&gt; {<br>                        result.success(mapOf(<br>                            &quot;API_KEY&quot; to BuildConfig.API_KEY,<br>                            &quot;BASE_URL&quot; to BuildConfig.BASE_URL,<br>                            &quot;FIREBASE_PROJECT_ID&quot; to BuildConfig.FIREBASE_PROJECT_ID,<br>                            &quot;ENVIRONMENT_NAME&quot; to BuildConfig.ENVIRONMENT_NAME<br>                        ))<br>                    }<br>                    else -&gt; result.notImplemented()<br>                }<br>            }<br>        }<br>    }<br>}</pre><p><strong>Register in MainActivity.kt:</strong></p><pre>override fun configureFlutterEngine(flutterEngine: FlutterEngine) {<br>    super.configureFlutterEngine(flutterEngine)<br>    EnvConfigPlugin.registerWith(flutterEngine)<br>}</pre><h3>Step 5: iOS Native Setup</h3><p><strong>Add to ios/Runner/Info.plist:</strong></p><pre>&lt;key&gt;API_KEY&lt;/key&gt;<br>&lt;string&gt;$(API_KEY)&lt;/string&gt;<br><br>&lt;key&gt;BASE_URL&lt;/key&gt;<br>&lt;string&gt;$(BASE_URL)&lt;/string&gt;<br><br>&lt;key&gt;FIREBASE_PROJECT_ID&lt;/key&gt;<br>&lt;string&gt;$(FIREBASE_PROJECT_ID)&lt;/string&gt;<br><br>&lt;key&gt;ENVIRONMENT_NAME&lt;/key&gt;<br>&lt;string&gt;$(ENVIRONMENT_NAME)&lt;/string&gt;</pre><p><strong>ios/Runner/EnvironmentConfig.swift:</strong></p><pre>import Foundation<br><br>class EnvironmentConfig {<br>    static func getValue(for key: String) -&gt; String {<br>        if let value = Bundle.main.object(forInfoDictionaryKey: key) as? String {<br>            return value<br>        }<br>        return &quot;&quot;<br>    }<br>    <br>    static var apiKey: String { getValue(for: &quot;API_KEY&quot;) }<br>    static var baseURL: String { getValue(for: &quot;BASE_URL&quot;) }<br>    static var environmentName: String { getValue(for: &quot;ENVIRONMENT_NAME&quot;) }<br>    <br>    static func getAllEnvironmentVariables() -&gt; [String: String] {<br>        return [<br>            &quot;API_KEY&quot;: apiKey,<br>            &quot;BASE_URL&quot;: baseURL,<br>            &quot;FIREBASE_PROJECT_ID&quot;: getValue(for: &quot;FIREBASE_PROJECT_ID&quot;),<br>            &quot;ENVIRONMENT_NAME&quot;: environmentName<br>        ]<br>    }<br>}</pre><p><strong>ios/Runner/AppDelegate.swift:</strong></p><pre>override func application(<br>    _ application: UIApplication,<br>    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?<br>) -&gt; Bool {<br>    let controller = window?.rootViewController as! FlutterViewController<br>    let envChannel = FlutterMethodChannel(<br>        name: &quot;com.myapp/env_config&quot;,<br>        binaryMessenger: controller.binaryMessenger<br>    )<br>    <br>    envChannel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) in<br>        if call.method == &quot;getAllEnv&quot; {<br>            result(EnvironmentConfig.getAllEnvironmentVariables())<br>        } else {<br>            result(FlutterMethodNotImplemented)<br>        }<br>    }<br>    <br>    GeneratedPluginRegistrant.register(with: self)<br>    return super.application(application, didFinishLaunchingWithOptions: launchOptions)<br>}</pre><p><strong>Add Xcode Build Phase:</strong></p><ol><li>Open ios/Runner.xcworkspace in Xcode</li><li>Runner → TARGETS &gt; Runner → Build Phases</li><li>“+” → “New Run Script Phase”</li><li>Script name: “Setup xcconfig”</li><li>Script content:</li></ol><pre>&quot;${PROJECT_DIR}/scripts/setup_xcconfig.sh&quot;</pre><p>6. Drag this script to the <strong>top</strong> (run first)</p><h3>Step 6: Use in Flutter</h3><p><strong>main.dart:</strong></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:myapp/core/env_config.dart&#39;;<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  <br>  // Load environment variables<br>  await EnvConfig.getAll();<br>  <br>  print(&#39;Environment: ${EnvConfig.environmentNameSync}&#39;);<br>  print(&#39;API URL: ${EnvConfig.baseURLSync}&#39;);<br>  <br>  runApp(MyApp());<br>}<br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;MyApp - ${EnvConfig.environmentNameSync}&#39;,<br>      home: HomePage(),<br>    );<br>  }<br>}</pre><p><strong>Use in API Client:</strong></p><pre>class ApiClient {<br>  final Dio _dio;<br>  <br>  ApiClient() : _dio = Dio(BaseOptions(<br>    baseUrl: EnvConfig.baseURLSync,<br>    headers: {<br>      &#39;X-API-Key&#39;: EnvConfig.apiKeySync,<br>    },<br>  ));<br>  <br>  Future&lt;Response&gt; get(String path) async {<br>    return await _dio.get(path);<br>  }<br>}</pre><h3>Usage</h3><h3>Initial Setup</h3><pre># 1. Create .env files<br>cp .env.example .env.dev<br>cp .env.example .env.staging<br>cp .env.example .env.prod<br><br># Edit each file with actual values<br># vim .env.dev<br># vim .env.staging<br># vim .env.prod<br># 2. Grant script execution permission<br>chmod +x scripts/generate_env_config.sh<br># 3. Generate environment config files<br>./scripts/generate_env_config.sh<br># 4. Configure iOS Build Phase (see Step 5)<br># 5. Test build<br>flutter build apk --flavor dev<br>flutter build ios --debug</pre><h3>Daily Usage</h3><pre># When changing environment variables<br># 1. Edit .env.dev, .env.staging, or .env.prod<br><br># 2. Run script<br>./scripts/generate_env_config.sh<br># 3. Build<br>flutter build apk --flavor dev --debug<br>flutter build apk --flavor staging --profile<br>flutter build apk --flavor prod --release<br>flutter build ios --debug    # dev<br>flutter build ios --profile  # staging<br>flutter build ios --release  # prod</pre><h3>CI/CD Integration</h3><p><strong>GitHub Actions Example:</strong></p><pre>name: Build and Deploy<br><br>on:<br>  push:<br>    branches: [ main, develop ]<br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    <br>    steps:<br>    - uses: actions/checkout@v2<br>    <br>    - name: Setup Flutter<br>      uses: subosito/flutter-action@v2<br>      <br>    - name: Create .env files from secrets<br>      run: |<br>        echo &quot;${{ secrets.ENV_DEV }}&quot; &gt; .env.dev<br>        echo &quot;${{ secrets.ENV_STAGING }}&quot; &gt; .env.staging<br>        echo &quot;${{ secrets.ENV_PROD }}&quot; &gt; .env.prod<br>    <br>    - name: Generate environment configs<br>      run: ./scripts/generate_env_config.sh<br>    <br>    - name: Build Android APK (Production)<br>      run: flutter build apk --flavor prod --release<br>    <br>    - name: Upload artifact<br>      uses: actions/upload-artifact@v2<br>      with:<br>        name: app-prod-release<br>        path: build/app/outputs/flutter-apk/app-prod-release.apk</pre><p><strong>Fastlane Integration:</strong></p><pre># fastlane/Fastfile<br><br>lane :build_dev do<br>  sh(&quot;../scripts/generate_env_config.sh&quot;)<br>  gradle(<br>    task: &quot;assemble&quot;,<br>    flavor: &quot;dev&quot;,<br>    build_type: &quot;Debug&quot;<br>  )<br>end<br>lane :build_prod do<br>  sh(&quot;../scripts/generate_env_config.sh&quot;)<br>  gradle(<br>    task: &quot;assemble&quot;,<br>    flavor: &quot;prod&quot;,<br>    build_type: &quot;Release&quot;<br>  )<br>end<br><br>--- <br><br>## How It Works<br><br>### Android Flow<br>```<br>1. .env.dev<br>   ↓<br>2. scripts/generate_env_config.sh<br>   ↓<br>3. android/gradle-dev.properties generated<br>   ↓<br>4. Gradle creates BuildConfig class<br>   public static final String API_KEY = &quot;dev_key&quot;;<br>   ↓<br>5. Access in Kotlin via BuildConfig.API_KEY<br>   ↓<br>6. Pass to Flutter via Method Channel<br>   ↓<br>7. Use in Dart via EnvConfig.apiKeySync<br>```<br><br><br>## iOS Flow<br><br>```<br>1. .env.dev<br>   ↓<br>2. scripts/generate_env_config.sh<br>   ↓<br>3. ios/Flutter/Environment/Debug.xcconfig generated<br>   API_KEY = dev_key<br>   BASE_URL = https:/$()/dev-api.com<br>   ↓<br>4. Xcode Build Phase: setup_xcconfig.sh<br>   Adds #include &quot;Environment/Debug.xcconfig&quot; to Debug.xcconfig<br>   ↓<br>5. During build, Info.plist $(API_KEY) replaced<br>   &lt;string&gt;dev_key&lt;/string&gt;<br>   ↓<br>6. Read in Swift via Bundle.main.object()<br>   ↓<br>7. Pass to Flutter via Method Channel<br>   ↓<br>8. Use in Dart via EnvConfig.apiKeySync<br>```</pre><h3>xcconfig URL Handling</h3><p>In xcconfig files, :// is interpreted as a comment:</p><pre># ❌ This doesn&#39;t work<br>BASE_URL = https://api.com  # Everything after // is a comment<br><br># ✅ Correct approach<br>BASE_URL = https:/$()/api.com  # $() is replaced with empty string at build time</pre><p>The script automatically converts:</p><pre># Convert :// to :/$()/<br>if [[ &quot;$value&quot; =~ :// ]]; then<br>    value=$(echo &quot;$value&quot; | sed &#39;s|://|:/$()/|g&#39;)<br>fi</pre><h3>Security Considerations</h3><h3>What Goes in Git</h3><p>✅ <strong>Safe (included in Git):</strong></p><ul><li>scripts/generate_env_config.sh</li><li>.env.example (template, no actual values)</li><li>android/app/env_config.gradle (structure only, no values)</li><li>ios/Runner/Info.plist ($(VARIABLE) format)</li><li>ios/Runner/EnvironmentConfig.swift (reading code only)</li><li>lib/core/env_config.dart (interface only)</li></ul><p>❌ <strong>Dangerous (excluded from Git):</strong></p><ul><li>.env.dev, .env.staging, .env.prod</li><li>android/gradle-*.properties</li><li>ios/Flutter/Environment/*.xcconfig</li><li>ios/scripts/setup_xcconfig.sh</li></ul><h3>.gitignore Configuration</h3><pre># Environment files (DO NOT COMMIT)<br>.env.dev<br>.env.staging<br>.env.prod<br><br># Android generated<br>android/gradle-*.properties<br># iOS generated<br>ios/Flutter/Environment/<br>ios/scripts/setup_xcconfig.sh<br># Keep templates<br>!.env.example</pre><h3>Team Collaboration Workflow</h3><pre># New team member onboarding<br>1. Clone repository<br>   git clone https://github.com/myteam/myapp.git<br><br>2. Create .env files<br>   cp .env.example .env.dev<br>   cp .env.example .env.staging<br>   cp .env.example .env.prod<br>3. Request actual keys from team lead<br>   (transmitted via secure channel)<br>4. Input actual values in .env files<br>5. Generate environment config<br>   ./scripts/generate_env_config.sh<br>6. Test build<br>   flutter run --flavor dev</pre><h3>CI/CD Security</h3><p>Use GitHub Secrets, GitLab CI/CD Variables, etc.:</p><pre># GitHub Actions<br>- name: Create .env files<br>  run: |<br>    echo &quot;${{ secrets.ENV_DEV }}&quot; &gt; .env.dev<br>    echo &quot;${{ secrets.ENV_STAGING }}&quot; &gt; .env.staging<br>    echo &quot;${{ secrets.ENV_PROD }}&quot; &gt; .env.prod<br><br>---<br><br>## Troubleshooting<br><br>### iOS Build Failure: &quot;Unknown configuration&quot;<br><br>**Symptom:**<br>```<br>error: Build input file cannot be found: &#39;.../Debug.xcconfig&#39;</pre><h3><strong>Solution:</strong></h3><pre># 1. Run Flutter build once to generate xcconfig<br>flutter build ios --debug<br><br># 2. Run environment config script<br>./scripts/generate_env_config.sh<br># 3. Build again<br>flutter build ios --debug<br><br>### Android Build Failure: &quot;BuildConfig undefined&quot;<br><br>**Symptom:**<br>```<br>error: cannot find symbol variable BuildConfig</pre><p><strong>Solution:</strong></p><pre># 1. Check gradle file<br>cat android/gradle-dev.properties<br># 2. Verify env_config included in build.gradle<br># Confirm this line exists in android/app/build.gradle:<br>apply from: &quot;$rootDir/app/env_config.gradle&quot;<br># 3. Clear Gradle cache<br>cd android<br>./gradlew clean<br>cd ..<br># 4. Rebuild<br>flutter build apk --flavor dev</pre><h3>xcconfig include not added</h3><p><strong>Symptom:</strong> Build succeeds but environment variables are empty</p><p><strong>Solution:</strong></p><pre># 1. Check Build Phase order<br># In Xcode, verify &quot;Setup xcconfig&quot; is at the top<br># 2. Check script execution permission<br>chmod +x ios/scripts/setup_xcconfig.sh<br># 3. Manually verify<br>cat ios/Flutter/Debug.xcconfig<br># Should contain #include &quot;Environment/Debug.xcconfig&quot;<br># 4. If missing, run manually<br>cd ios<br>./scripts/setup_xcconfig.sh<br>cd ..</pre><h3>URL :// not loading properly</h3><p><strong>Symptom:</strong></p><pre>baseURL = &quot;https&quot; // Everything after // disappears</pre><p><strong>Cause:</strong> xcconfig interprets :// as a comment</p><p><strong>Solution:</strong> Verify script automatically converts to :/$()/:</p><pre>cat ios/Flutter/Environment/Debug.xcconfig<br># Should be: BASE_URL = https:/$()/api.com<br><br>### Method Channel no response<br>**Symptom:**<br>```<br>Failed to load environment variables: MissingPluginException</pre><h3><strong>Android Solution:</strong></h3><pre>// Verify in MainActivity.kt<br>override fun configureFlutterEngine(flutterEngine: FlutterEngine) {<br>    super.configureFlutterEngine(flutterEngine)<br>    EnvConfigPlugin.registerWith(flutterEngine) // Check this line<br>}</pre><p><strong>iOS Solution:</strong></p><pre>// Verify Method Channel code in AppDelegate.swift<br>// Check channel name matches:<br>// Dart: &#39;com.myapp/env_config&#39;<br>// Native: &quot;com.myapp/env_config&quot;</pre><h3>Performance Considerations</h3><h3>Build Time Impact</h3><ul><li><strong>Script execution time</strong>: &lt; 1 second</li><li><strong>Gradle build</strong>: No impact (properties reading is very fast)</li><li><strong>Xcode build</strong>: No impact (xcconfig include is standard mechanism)</li></ul><h3>Runtime Performance</h3><pre>// ✅ Good pattern: Load once at app start<br>void main() async {<br>  await EnvConfig.getAll();  // Cached<br>  runApp(MyApp());<br>}</pre><pre>// ✅ Subsequent synchronous access (fast)<br>final apiKey = EnvConfig.apiKeySync;  // Returns immediately from cache</pre><pre>// ❌ Bad pattern: Async call every time<br>final apiKey = await EnvConfig.get(&#39;API_KEY&#39;);  // Unnecessary async</pre><h3>Memory Usage</h3><ul><li>Environment variables: Typically &lt; 1KB</li><li>Method Channel overhead: Negligible</li><li>Additional memory from caching: Minimal</li></ul><h3>Extensibility</h3><h3>Adding New Environments</h3><pre># 1. Create .env file<br>cp .env.example .env.testing<br><br># 2. Add Android flavor (env_config.gradle)<br>testing {<br>    dimension &quot;environment&quot;<br>    // ...<br>}<br># 3. Add iOS configuration<br># Create Testing configuration in Xcode<br># 4. Update script<br>ENVIRONMENTS=(&quot;dev&quot; &quot;staging&quot; &quot;testing&quot; &quot;prod&quot;)</pre><h3>Adding New Environment Variables</h3><p>Simply add to .env files — automatically handled:</p><pre># Add to .env.dev<br>NEW_FEATURE_FLAG=true<br>ANALYTICS_ENDPOINT=https://analytics.myapp.com</pre><p>Rerun script:</p><pre>./scripts/generate_env_config.sh</pre><p>Use:</p><pre>final featureEnabled = EnvConfig.getSync(&#39;NEW_FEATURE_FLAG&#39;) == &#39;true&#39;;</pre><h3>Supporting Other Platforms</h3><p>For web or desktop:</p><pre>// Modify lib/core/env_config.dart<br>static Future&lt;Map&lt;String, String&gt;&gt; getAll() async {<br>  if (kIsWeb) {<br>    // Web: use compile-time constants<br>    return const {<br>      &#39;API_KEY&#39;: String.fromEnvironment(&#39;API_KEY&#39;),<br>      &#39;BASE_URL&#39;: String.fromEnvironment(&#39;BASE_URL&#39;),<br>    };<br>  } else if (Platform.isAndroid || Platform.isIOS) {<br>    // Existing Method Channel approach<br>    final result = await _channel.invokeMethod&lt;Map&gt;(&#39;getAllEnv&#39;);<br>    return Map&lt;String, String&gt;.from(result ?? {});<br>  } else {<br>    // Desktop: load from file<br>    return _loadFromFile();<br>  }<br>}</pre><h3>Comparison with Alternatives</h3><h3>flutter_dotenv</h3><pre>// flutter_dotenv approach<br>await dotenv.load(fileName: &quot;.env&quot;);<br>final apiKey = dotenv.env[&#39;API_KEY&#39;];</pre><p><strong>Pros:</strong></p><ul><li>Simple setup</li><li>Pure Dart solution</li></ul><p><strong>Cons:</strong></p><ul><li>.env file included in app (security risk)</li><li>Runtime loading (performance overhead)</li><li>No native code access</li><li>Difficult environment separation</li></ul><h3>envied Package</h3><pre>// envied approach<br>@Envied()<br>abstract class Env {<br>  @EnviedField(varName: &#39;API_KEY&#39;)<br>  static const String apiKey = _Env.apiKey;<br>}</pre><p><strong>Pros:</strong></p><ul><li>Compile-time inclusion</li><li>Type safety</li></ul><p><strong>Cons:</strong></p><ul><li>Code generation required</li><li>Increased build time</li><li>Complex native access</li><li>Complex CI/CD setup</li></ul><h3>Our Approach Advantages</h3><pre>Feature               | flutter_dotenv | envied | Our Approach  |<br>Security (Git safe)   | ❌              | ⚠️     | ✅            |<br>Native access         | ❌              | ❌     | ✅            |<br>Build-time injection  | ❌              | ✅     | ✅            |<br>Runtime performance   | ⚠️              | ✅     | ✅            |<br>Environment separation| ⚠️              | ⚠️     | ✅            |<br>CI/CD friendly        | ⚠️              | ❌     | ✅            |<br>Setup complexity      | Low             | Medium | Medium       |</pre><h3>Real-World Use Cases</h3><h3>Case 1: Startup MVP</h3><p><strong>Situation:</strong></p><ul><li>Small team (3 people)</li><li>Only Dev/Prod environments needed</li><li>Using Firebase + REST API</li></ul><p><strong>Implementation:</strong></p><pre># .env.dev<br>API_KEY=firebase_dev_key<br>BASE_URL=https://dev-api.startup.com<br>FIREBASE_PROJECT_ID=startup-dev<br>SENTRY_DSN=https://sentry.io/dev-project<br><br># .env.prod<br>API_KEY=firebase_prod_key<br>BASE_URL=https://api.startup.com<br>FIREBASE_PROJECT_ID=startup-prod<br>SENTRY_DSN=https://sentry.io/prod-project</pre><p><strong>Results:</strong></p><ul><li>Faster development (easy environment switching)</li><li>Production key leakage prevented</li><li>Automatic Firebase project switching</li></ul><h3>Case 2: Enterprise App</h3><p><strong>Situation:</strong></p><ul><li>Large team (20+ developers)</li><li>Dev/QA/Staging/Prod environments</li><li>Multi-region support</li><li>Strict security requirements</li></ul><p><strong>Implementation:</strong></p><pre># .env.dev<br>API_KEY=dev_key<br>BASE_URL=https://dev-api.company.com<br>REGION=us-west-2<br>FEATURE_FLAG_ENDPOINT=https://dev-flags.company.com<br>LOG_LEVEL=debug<br><br># .env.qa<br>API_KEY=qa_key<br>BASE_URL=https://qa-api.company.com<br>REGION=us-west-2<br>FEATURE_FLAG_ENDPOINT=https://qa-flags.company.com<br>LOG_LEVEL=info<br># .env.staging<br>API_KEY=staging_key<br>BASE_URL=https://staging-api.company.com<br>REGION=us-east-1<br>FEATURE_FLAG_ENDPOINT=https://staging-flags.company.com<br>LOG_LEVEL=warn<br># .env.prod<br>API_KEY=prod_key<br>BASE_URL=https://api.company.com<br>REGION=eu-west-1<br>FEATURE_FLAG_ENDPOINT=https://flags.company.com<br>LOG_LEVEL=error</pre><p><strong>Results:</strong></p><ul><li>Passed security audit</li><li>Perfect environment isolation</li><li>Reduced onboarding time (1 week → 1 day)</li></ul><h3>Case 3: B2B SaaS</h3><p><strong>Situation:</strong></p><ul><li>White-label app (customer-specific customization)</li><li>Same codebase, different branding</li><li>Customer-specific API endpoints</li></ul><p><strong>Implementation:</strong></p><pre># .env.client-a<br>CLIENT_NAME=ClientA<br>API_KEY=client_a_key<br>BASE_URL=https://client-a.api.saas.com<br>BRAND_COLOR=#FF5733<br>APP_NAME=ClientA App<br>LOGO_URL=https://cdn.saas.com/client-a/logo.png<br># .env.client-b<br>CLIENT_NAME=ClientB<br>API_KEY=client_b_key<br>BASE_URL=https://client-b.api.saas.com<br>BRAND_COLOR=#3498DB<br>APP_NAME=ClientB Solution<br>LOGO_URL=https://cdn.saas.com/client-b/logo.png</pre><p><strong>Results:</strong></p><ul><li>Single codebase supports multiple brands</li><li>Reduced client addition time (2 weeks → 2 hours)</li><li>Complete deployment automation</li></ul><h3>Conclusion</h3><h3>Key Takeaways</h3><ol><li><strong>Security</strong>: Sensitive information never committed to Git</li><li><strong>Automation</strong>: Environment automatically injected at build time</li><li><strong>Standards</strong>: Uses Flutter and native standard mechanisms</li><li><strong>Maintainability</strong>: Single .env file manages all platforms</li></ol><h3>Checklist</h3><p>Initial setup:</p><ul><li>[ ] Create .env.dev, .env.staging, .env.prod</li><li>[ ] Grant execution permission to scripts/generate_env_config.sh</li><li>[ ] Add environment files to .gitignore</li><li>[ ] Apply Android env_config.gradle</li><li>[ ] Register Android EnvConfigPlugin</li><li>[ ] Add iOS Build Phase setup_xcconfig.sh</li><li>[ ] Add variable references to iOS Info.plist</li><li>[ ] Add Method Channel to iOS AppDelegate</li><li>[ ] Use Flutter EnvConfig</li><li>[ ] Test builds in each environment</li></ul><h3>Next Steps</h3><p>Apply this system to your Flutter app now:</p><ol><li><strong>Get Started</strong>: Clone <a href="https://github.com/yourusername/flutter-env-config">GitHub Repository</a></li><li><strong>Customize</strong>: Modify environment variables for your project</li><li><strong>Test</strong>: Verify builds in each environment</li><li><strong>Deploy</strong>: Integrate with CI/CD pipeline</li></ol><h3>Feedback Welcome</h3><p>Did this guide help you? Leave a comment if you have suggestions or questions!</p><p><strong>Tags</strong>: #Flutter #Mobile #DevOps #Security #EnvironmentVariables #BuildAutomation #iOS #Android #CICD</p><p><strong>Source Code</strong>: Complete example code available on <a href="https://github.com/yourusername/flutter-env-config">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9aa7b822ece" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Bloc, UseCase, Repository, and Service in Flutter Architecture]]></title>
            <link>https://medium.com/@hojunrooneybaek/understanding-bloc-usecase-repository-and-service-in-flutter-architecture-e8ec4e420521?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8ec4e420521</guid>
            <category><![CDATA[bloc]]></category>
            <category><![CDATA[get-it]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Thu, 18 Dec 2025 06:16:43 GMT</pubDate>
            <atom:updated>2025-12-18T06:16:43.326Z</atom:updated>
            <content:encoded><![CDATA[<p>When building a scalable Flutter application, one of the most common questions is:</p><p>“Where should this logic live?”</p><p>To answer that clearly, many teams adopt a layered architecture using Bloc, UseCase, Repository, and Service.</p><p>Each layer has a single responsibility, and together they help keep your app maintainable, testable, and scalable.</p><p>This article explains what each layer does, why it exists, and how they work together — from a practical, real-world perspective.</p><p>High-Level Architecture Overview</p><pre>UI (Widgets)<br> ↓<br>Bloc<br> ↓<br>UseCase<br> ↓<br>Repository<br> ↓<br>Service (API / DB / SDK)</pre><ul><li>Upper layers focus on business rules and state</li><li>Lower layers focus on technical implementation</li><li>Dependencies always point downward</li></ul><h3>1. Bloc — UI State Management</h3><p>What is Bloc responsible for?<br>Bloc manages UI state and reacts to user events.</p><pre>on&lt;LoginSubmitted&gt;((event, emit) async {<br>  emit(LoginLoading());<br>  final result = await loginUseCase(event.email, event.password);<br>  emit(result.isSuccess ? LoginSuccess() : LoginFailure());<br>});</pre><p>Responsibilities</p><ul><li>Handle UI events</li><li>Call UseCases</li><li>Convert results into UI states (Loading / Success / Error)</li></ul><p><strong>What Bloc should NOT do </strong>❌</p><ul><li>Call APIs directly</li><li>Contain business rules</li><li>Perform data transformations</li></ul><p>Bloc does not decide business logic. It only reflects state.</p><h3>2. UseCase — Business Rules &amp; Policies</h3><p>What is a UseCase?</p><p>A UseCase represents a single business action in your application.</p><pre>class LoginUseCase {<br>  final AuthRepository repository;<br><br>  Future&lt;LoginResult&gt; call(String email, String password) {<br>    if (email.isEmpty) {<br>      throw InvalidEmailException();<br>    }<br>    return repository.login(email, password);<br>  }<br>}</pre><p>Responsibilities</p><ul><li>Enforce business rules</li><li>Validate inputs</li><li>Coordinate multiple repositories if needed</li></ul><p>Key Characteristics</p><ul><li>Pure Dart (no Flutter dependency)</li><li>No UI knowledge</li><li>Easy to unit test</li></ul><p>Think of UseCases as your product’s business specification written in code.</p><h3>3. Repository — Abstraction Layer (Contract)</h3><p><strong>What does a Repository do?</strong></p><p>A Repository defines what data is needed, not how it is fetched.</p><pre>abstract class AuthRepository {<br>  Future&lt;LoginResult&gt; login(String email, String password);<br>}</pre><p><strong>Responsibilities</strong></p><ul><li>Abstract data sources</li><li>Return domain models</li><li>Act as a replacement point for mocks in tests</li></ul><p><strong>Why this matters</strong></p><p>The UseCase doesn’t care whether data comes from:</p><ul><li>REST API</li><li>Local database</li><li>Cache</li><li>Firebase</li></ul><p>Repository is a contract, not an implementation.</p><h3>4. Service — Technical Implementation</h3><p><strong>What is a Service?</strong></p><p>Services interact with external systems such as APIs, databases, or SDKs.</p><pre>class AuthApiService {<br>  Future&lt;LoginResponse&gt; login(String email, String password) {<br>    return dio.post(&#39;/login&#39;, data: {…});<br>  }<br>}</pre><p><strong>Responsibilities</strong></p><ul><li>API calls (Dio, HTTP)</li><li>Database access</li><li>Firebase / platform SDKs</li><li>DTO parsing</li></ul><p><strong>Characteristics</strong></p><ul><li>Highly coupled to technology</li><li>Most likely to change over time</li></ul><p>Services are replaceable. Business rules are not.</p><p><strong>How Repository Connects Service and UseCase</strong></p><pre>class AuthRepositoryImpl implements AuthRepository {<br>  final AuthApiService api;<br><br>  @override<br>  Future&lt;LoginResult&gt; login(String email, String password) async {<br>    final response = await api.login(email, password);<br>    return response.toDomain();<br>  }<br>}</pre><p>•	Service → handles raw data (DTO)</p><p>•	Repository → converts data into domain models</p><p><strong>Dependency Direction (Important)</strong></p><pre>Bloc → UseCase → Repository → Service</pre><ul><li>Upper layers never depend on lower-level details</li><li>Lower layers know nothing about UI or business rules</li></ul><p>This separation keeps changes localized and safe.</p><p><strong>One-Line Summary per Layer</strong></p><p>Layer | Purpose</p><p>Bloc	Manages UI state</p><p>UseCase	Executes business rules</p><p>Repository	Defines data contracts</p><p>Service	Handles technical data access</p><p>Practical Rule of Thumb</p><p>When deciding where code belongs, ask:</p><ol><li>Is it UI state? → Bloc</li><li>Is it a business rule or policy? → UseCase</li><li>Is it data abstraction? → Repository</li><li>Is it API / DB / SDK logic? → Service</li></ol><p>Why This Architecture Works Well in Flutter</p><ul><li>Scales cleanly as features grow</li><li>Makes unit testing straightforward</li><li>Works with Bloc, MVVM, or other state managers</li><li>Plays well with dependency injection tools like GetIt</li></ul><p><strong>Final Thoughts</strong></p><p>This separation may feel verbose for small apps,</p><p>but once your app grows, this structure prevents complexity from exploding.</p><p>Clean boundaries today save refactoring tomorrow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8ec4e420521" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Copying Android App Cache Data with ADB]]></title>
            <link>https://medium.com/@hojunrooneybaek/copying-android-app-cache-data-with-adb-f15a2709d456?source=rss-9c8ed2e3abaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f15a2709d456</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[files]]></category>
            <category><![CDATA[adb]]></category>
            <dc:creator><![CDATA[Hojun Rooney Baek]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 04:54:58 GMT</pubDate>
            <atom:updated>2025-11-28T05:18:45.490Z</atom:updated>
            <content:encoded><![CDATA[<p>When debugging an Android app, you’ll often need to inspect files stored inside the app’s internal storage — for example, a cached database.</p><p>One simple approach is to use the run-as command to temporarily access the app’s data and output it into a location you can pull locally.</p><p>Below is a walkthrough of the process for extracting a cached DB file (cache/customImageCache/cache.db) and bringing it onto your local machine.</p><h3>1. Enter the App Context with run-as</h3><pre>adb shell run-as com.ezcocoa.app</pre><p>This works only if the app is debuggable. Once inside, you can freely access the app’s internal storage.</p><h3>2. Check the File Path</h3><pre>ls cache/customImageCache/</pre><p>you need to identify the exact path of the file you want to extract.</p><h3>3. Exit the run-as Shell</h3><pre>exit</pre><h3>4. Pull the File to Your Local Machine</h3><pre>adb shell &quot;run-as  com.ezcocoa.app cat cache/customImageCache/cache.db&quot; &gt; cache.db</pre><p>Creates a file in the local directory that matches the target file.</p><p>Now you can open the DB locally using your favorite SQLite viewer, inspect queries, or debug caching behavior.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f15a2709d456" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>