<?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 Aymen Chouirfi on Medium]]></title>
        <description><![CDATA[Stories by Aymen Chouirfi on Medium]]></description>
        <link>https://medium.com/@aymen.chouirfi?source=rss-aea86ab24796------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tt48TTwTZik7I43ArXPdDw.jpeg</url>
            <title>Stories by Aymen Chouirfi on Medium</title>
            <link>https://medium.com/@aymen.chouirfi?source=rss-aea86ab24796------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:01:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aymen.chouirfi/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[From Brilliant to Brutal: The Fall of a Tech Star]]></title>
            <link>https://medium.com/@aymen.chouirfi/from-brilliant-to-brutal-the-fall-of-a-tech-star-2b2d6098c41e?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b2d6098c41e</guid>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 14:05:11 GMT</pubDate>
            <atom:updated>2026-10-08T14:05:11.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtXOuWjWwkTWAx5PMD8cOA.png" /><figcaption>Image generated with ChatGPT</figcaption></figure><p>In some software development environments, a highly skilled individual — often referred to as the “technical star” — can dominate discussions and wield disproportionate influence. Managers, believing the success of projects relies heavily on this person’s expertise, may defer to their decisions without question. However, this dynamic can overshadow other contributors, foster daily stress, and undermine collaborative spirit. Left unaddressed, the toxic behavior can spread, causing rifts that compromise both morale and productivity.</p><h3>Recognizing the Toxic Dynamic</h3><p><strong>Overbearing Presence and Managerial Misperception</strong></p><p>Because the technical star is seen as indispensable, they may overshadow other team members’ input. Their dominant voice often leads managers to assume that most work and innovation hinges on this individual. Consequently, the toxic star gains leverage to impose personal terms, further cementing their undue influence.</p><p><strong>Dividing the Team into Clans</strong></p><p>The star’s high visibility and close ties to management can split the group into factions: supporters — drawn by ambition or fear — and those who resist, risking marginalization. This “us versus them” culture undermines trust, stifles open collaboration, and creates a tense atmosphere where individuals hesitate to share ideas.</p><p><strong>The Daily Toll on “Double-Penalized” Victims</strong></p><p>Those who dare to challenge or question the star frequently suffer twofold consequences.</p><ul><li><strong>Constant Criticism and Stress</strong>: Under persistent scrutiny, these individuals experience ongoing anxiety that takes a toll on focus and confidence.</li><li><strong>Greater Likelihood of Mistakes</strong>: High stress can lead to errors. Unfortunately, every slip-up becomes ammunition for the toxic star to reinforce negative perceptions, further discrediting these team members in the eyes of management.</li><li><strong>Perceived Lack of Engagement</strong>: Fearing additional conflict or criticism, they may withdraw, speak up less, or avoid taking risks — only to be blamed later for “not being involved enough.”</li></ul><p><strong>Contagious Negativity</strong></p><p>Toxicity seldom remains confined to one person. When others see that disrespectful or manipulative actions go unchecked, they may mimic similar behaviors. In this way, negativity spreads, weakening trust and complicating cross-team projects across the organization.</p><h3>Why Swift Action Is Essential ?</h3><p><strong>Cumulative Stress and Errors</strong></p><p>Toxic behavior inserts tension into everyday interactions, causing communication breakdowns and a higher likelihood of mistakes among those living under constant pressure. Unresolved, this environment can do lasting damage to team morale.</p><p><strong>High Skill Doesn’t Justify Harmful Attitudes</strong></p><p>While technical expertise is valuable, allowing one individual to intimidate or overshadow colleagues tells the entire organization that respect and teamwork matter less than perceived star power.</p><p><strong>Preventing Further Contagion</strong></p><p>Taking decisive steps to address the toxic behavior stops it from spreading. A clear message that such attitudes are unacceptable protects the broader organizational culture and morale.</p><p><strong>Potential Rebound for Team Performance</strong></p><p>If coaching or mediation fail, removing the toxic star may become necessary. Although losing a skilled contributor can feel risky, teams often recover quickly — renewing collaboration, trust, and overall productivity without the shadow of toxicity.</p><h3>Managing the Situation Effectively</h3><p><strong>Immediate Managerial Intervention</strong></p><p>Address toxic behavior early through direct conversations, written warnings, or mediation. Swift, firm responses demonstrate the organization’s commitment to respect and fairness.</p><p><strong>Clear Conduct and Performance Guidelines</strong></p><p>Documenting standards of behavior (e.g., in a code of conduct) reduces ambiguity. When toxic actions occur, managers can respond objectively rather than relying on personal judgments.</p><p><strong>Balanced Evaluation Metrics</strong></p><p>Performance reviews should account for both technical outcomes and interpersonal skills. By rewarding collaboration and respect, leaders send a powerful signal that culture and competence go hand in hand.</p><p><strong>Open Feedback Channels</strong></p><p>Encourage honest dialogue — vertically and laterally. Town halls, anonymous surveys, or confidential check-ins create safe spaces for team members to voice concerns, helping identify and address toxicity before it festers.</p><p><strong>Decisive Removal if Necessary</strong></p><p>If corrective measures fail and the toxic star continues to harm the team, separation may be the only viable solution. Though challenging, it can be crucial for restoring a positive work environment where everyone can thrive.</p><h3>Conclusion</h3><p>A toxic “technical star” can dominate a workplace to the point where other voices are stifled, stress levels soar, and mistakes multiply — giving the star even more leverage to criticize. This pattern can become self-perpetuating, creating lasting damage unless leaders intervene. Swift action — ranging from mediation to, if needed, removal — ensures that while technical skill is valued, it is never allowed to overshadow dignity, respect, and the collective success of the team. By holding all members to clear interpersonal standards, organizations foster an environment where collaboration flourishes and everyone’s contributions can truly shine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b2d6098c41e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross-Platform vs Native: The Distraction Behind Real Budget Leaks]]></title>
            <link>https://medium.com/@aymen.chouirfi/cross-platform-vs-native-the-distraction-behind-real-budget-leaks-13ade3814128?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/13ade3814128</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[native-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 09:06:46 GMT</pubDate>
            <atom:updated>2026-01-19T09:06:46.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKNz71ZYTlf9ixgib2jC0g.png" /><figcaption><strong>Technology choices matter — but most software budget overruns come from decisions, not frameworks</strong></figcaption></figure><p>When leaders discuss mobile app development costs, one argument quickly becomes dogma</p><blockquote><strong><em>“Cross-platform development costs less than native.”</em></strong></blockquote><p>It’s true that cross-platform approaches can <strong>reduce initial development costs and time-to-market</strong>, but this framing misses the real drivers of budget overruns — and in many cases, even the numbers quoted are partial. The real costs in software projects seldom come from tool choice alone.</p><p>In this article, we explore <strong>what the data actually says</strong> — about cross-platform economics <em>and</em> where budgets truly leak.</p><h3>What the Data Says About Native vs Cross-Platform Costs</h3><p>Industry estimates suggest that choosing cross-platform development can save <a href="https://www.forasoft.com/blog/article/native-or-cross-platform-application-213"><strong>30–40 % on development costs and time</strong></a><strong> </strong>compared to building separate native apps for iOS and Android. This is largely due to a <strong>single shared codebase</strong> and reduced duplication of effort.</p><p>Another <a href="https://www.clariontech.com/blog/native-vs-cross-platform-app-development-whats-the-right-choice">source</a> reports similar figures, estimating that cross-platform apps <strong>reduce launch time by ~40 % and costs by ~30 %</strong>, with maintenance advantages because a single codebase means fewer duplicate updates.</p><p>Cross-platform solutions can also reduce the typical development time, accelerating delivery and shrinking team size. Some benchmarks suggest time savings of more than <a href="https://research2guidance.com/cross-platform-tools-can-save-more-than-30-of-app-development-time"><strong>30 % for many teams</strong></a>, with a third claiming even greater gains.</p><p>However, these figures are <em>development-centric</em> — they <strong>don’t capture long-term costs</strong> related to scope creep, rework, architectural choices, or technical debt. That’s where many teams quietly overspend.</p><h3>Where Budgets Really Leak — Stats Don’t Lie</h3><p>Across technology industries, research shows that <strong>project cost overruns are extremely common</strong>:</p><ul><li><a href="https://arxiv.org/abs/2210.01573">Historical analysis</a> of IT projects reveals that <strong>the average cost overrun is around 27 %</strong>, with a “fat-tail” of extreme overruns that many conventional models miss.</li><li><a href="https://arxiv.org/abs/1304.0265">Classic research </a>on IT projects finds that one in six projects ends up as a “Black Swan,” exceeding budgets by 200 %, with schedule overruns close to 70 %.</li><li><a href="https://www.betabreakers.com/blog/software-survival-in-2024-understanding-2023-project-failure-statistics-and-the-role-of-quality-assurance">Software delivery statistics</a> show that <strong>scope creep, unclear requirements, and insufficient stakeholder alignment</strong> frequently drive delays and overruns. One industry analysis found scope and requirement issues present in a large portion of failing projects.</li><li>As many as <a href="https://www.forecast.app/blog/66-of-enterprise-software-projects-have-cost-overruns"><strong>66 % of enterprise software projects exceed their budgets</strong></a>, with scope definition and change drive cited as major contributors.</li></ul><p>What is <em>not</em> typically tracked in these surveys is how often teams attribute overruns incorrectly to technical stacks rather than to organizational and process issues — yet this misattribution is widespread in executive conversations.</p><h3>Cross-Platform vs Native: Real Trade-offs</h3><p>The cost advantage of cross-platform development at the outset is real, but it comes with trade-offs that are often overlooked in budget discussions:</p><p><a href="https://www.codingpixel.com/native-vs-cross-platform-app-development"><strong>Performance and UX</strong></a><strong>:</strong> Native apps frequently outperform cross-platform counterparts because they are optimized for each platform’s architecture and APIs.</p><p><a href="https://www.fullestop.com/blog/native-vs-cross-platform-apps-development-costs"><strong>Maintenance complexity</strong></a><strong>:</strong> Cross-platform frameworks can simplify updates initially, but framework limitations or lagging support for new platform features may incur unexpected native workarounds later.</p><p>These nuances often matter little <em>if the project’s scope is tightly defined and simple</em>. But for complex applications or long-term products, they matter a lot.</p><h3>Why the Technical Debate Distracts from the Real Issues</h3><p>Focusing too narrowly on <em>native vs cross-platform</em> fosters a false sense of control because it seems measurable: “percent saved here, percent slower there.” But the data shows that <strong>most overruns come from process and organizational issues</strong>, not structural platform costs.</p><p>Common sources of leakage include:</p><h4>1. Scope and Feature Creep</h4><p><a href="https://www.researchgate.net/publication/342682685_The_Impact_of_Scope_Creep_on_Project_Success_An_Empirical_Investigation">Feature creep</a> — the continuous expansion of requirements beyond the original plan — is one of the most significant causes of budget overruns in software projects. Teams add features that sound valuable <em>in theory</em>, but this expansion delays delivery and consumes resources without delivering proportionate value. Clear evidence shows that poor requirements and scope management are associated with project failure and cost increases.</p><h4>2. Poor Planning and Alignment</h4><p>Projects without clear success criteria, well-defined scope, and aligned stakeholders tend to lose budget rapidly. <a href="https://raznameh.org/why-71-of-software-projects-failed-to-meet-these-three-criteria-on-time-on-budget-and-with-satisfactory-results">Research indicates that <strong>poor planning and monitoring correlates strongly with overruns and scope creep</strong></a>, leading to missed deadlines and wasted resources.</p><h4>3. Communication and Governance Breakdowns</h4><p>Communication gaps and inadequate involvement from senior leadership are also <a href="https://www.betabreakers.com/blog/software-survival-in-2024-understanding-2023-project-failure-statistics-and-the-role-of-quality-assurance">repeatedly cited</a> as contributors to project failure, compounding misunderstanding about budget risk and risk mitigation.</p><h3>What This Means for Decision-Makers</h3><p>The choice between native and cross-platform development is <strong>an important tactical decision</strong>, but <strong>not a strategic cost driver by itself</strong>.</p><p>When teams obsess over frameworks without addressing fundamental drivers of cost, they often create a <em>distraction</em> that masks the real culprits — and the data supports this view.</p><h3>The smarter conversation</h3><p>Decision-makers should focus on:</p><ul><li>Defining outcome-based scope with measurable success criteria.</li><li>Avoiding feature creep through disciplined prioritization.</li><li>Ensuring teams have the right skills for the chosen architecture and domain.</li><li>Investing in planning, communication, and governance mechanisms.</li></ul><p>These are the <strong>true levers of cost control</strong> — and they matter far more than whether you select Flutter, React Native, Swift, or Kotlin.</p><h3>Conclusion</h3><p>Yes — cross-platform approaches can reduce initial development cost by 30–40 % or more.</p><p>Yes — native approaches often yield superior performance.</p><p><strong>But neither of these choices drives budget failures. Poor decisions, unclear scope, and unmanaged complexity do.</strong></p><p>In an industry where up to two-thirds of software projects exceed budgets, and where overruns can exceed 200 %, the most expensive thing you can do is focus on the wrong problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13ade3814128" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Assembly Line to Scrum Board: The Clash of V-Model and Agile in Automotive]]></title>
            <link>https://medium.com/@aymen.chouirfi/from-assembly-line-to-scrum-board-the-clash-of-v-model-and-agile-in-automotive-31a623769c8e?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/31a623769c8e</guid>
            <category><![CDATA[automotive-industry]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[agile-methodology]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[project-management]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Wed, 07 May 2025 07:45:31 GMT</pubDate>
            <atom:updated>2025-05-07T07:45:31.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtsKNEXV3RTaiIG55IDgcw.jpeg" /></figure><p>I spent two years developing iOS apps in the automotive world, and let’s just say it’s been one wild ride. On one side, you’ve got the <strong>electro-mechanical engineering teams</strong> operating on a very traditional <strong>V-model</strong>, which is a sequential (and sometimes lengthy) process. On the other, you have <strong>software teams</strong> like mine, running on <strong>Scrum Agile</strong> — iterative, fast-paced, and flexible.</p><p>The clash of these two mindsets often sparked everything from small frustrations to full-blown project chaos. Below, I share my experiences, discuss why this is a <strong>known issue</strong>, and propose some practical solutions to bridge the gap.</p><h3>1. The Clash: A V-Model vs. Agile Face-Off</h3><p><strong>1.1 Rigid specifications vs. Constant change</strong></p><p>• <strong>V-model</strong>: Everything starts with a massive requirements document, which is supposed to stay stable until the very end.</p><p>• <strong>Agile</strong>: We adapt requirements at the end of every sprint (or sometimes even daily), responding to user feedback and market shifts.</p><p>I can’t tell you how many times we’d start building a feature based on the official specs, only to learn — two sprints later — that the mechanical design changed and the requirements we got at the outset no longer made sense.</p><p><strong>1.2 Different rhythms and milestones</strong></p><p>• <strong>V-model</strong>: Typically uses major milestone gates (design freeze, prototype validation, final validation) every few months.</p><p>• <strong>Agile</strong>: Delivers incremental value in short sprints (1–4 weeks).</p><p>While we were shipping iterative updates every few weeks, the electro-mechanical side might still have been finalizing hardware. When they discovered a design flaw and pivoted, we ended up rewriting code to match the new specs — a time sink.</p><p><strong>1.3 Communication breakdowns</strong></p><p>• <strong>V-model</strong>: Changes are often communicated at the end of big phases, which can be months long.</p><p>• <strong>Agile</strong>: Lives on rapid feedback loops — daily stand-ups, sprint reviews, retrospectives.</p><p>When mechanical specs evolved, we sometimes heard about it too late, leading to rework, missed deadlines, and a lot of “didn’t we already finish that feature?” moments.</p><h3>2. Why This Is a Known Issue (and Why It’s Costly)</h3><p>Anyone who’s worked at the intersection of <strong>hardware and software</strong> probably sees this coming. Traditional hardware engineering has historically relied on <strong>linear</strong> flows because of safety, regulatory, and supply-chain considerations — especially in the automotive industry. Meanwhile, <strong>software development</strong> typically favors <strong>iterative</strong> approaches that handle complexity through constant feedback.</p><p><strong>2.1 The Cost of Misalignment</strong></p><p>• <strong>Rework</strong>: According to research by Capers Jones, <strong>between 40% and 50% of all software effort</strong> can be spent on rework if requirements are not well-managed early on.</p><p>• <strong>Project Failure</strong>: The Standish Group’s “Chaos Report” frequently cites <strong>poor communication and changing requirements</strong> as leading causes of cost overruns and project failures in software.</p><p>• <strong>Late Discovery = High Cost</strong>: INCOSE (International Council on Systems Engineering) points out that <strong>the majority of a product’s lifecycle costs are locked in during early design</strong>. Changes made late in the cycle (after hardware decisions) can be exponentially more expensive.</p><p>In short, every time the mechanical team modifies something fundamental — especially late in their V-model phases — software teams can end up redoing days or even weeks of work. This cost multiplies across large teams and extended timelines, draining budgets and delaying time-to-market.</p><h3>3. Proposed Solutions: Building the Bridge</h3><p><strong>3.1 Hybrid Governance (V + Agile Combined)</strong></p><p>• <strong>Align major V-model milestones with Agile sprints.</strong></p><p>• Set shorter, more frequent checkpoints in the electro-mechanical timeline to avoid last-minute changes blindsiding the software team.</p><p>• This could mean “mini-gates” or “mini-design-reviews” aligning with sprint boundaries.</p><p><strong>3.2 Create a “Bridge” Role</strong></p><p>• <strong>Technical Coordinator / Hybrid Product Owner</strong>:</p><p>• One person (or a small team) keeps an eye on evolving mechanical specs and translates them into the software backlog — <strong>in real-time</strong>.</p><p>• This single point of contact reduces communication lag and ensures clarity on both sides.</p><p><strong>3.3 Cross-Team Rituals</strong></p><p>• <strong>Monthly Sync</strong>: A short stand-up across hardware and software.</p><p>• <strong>Shared Sprint Reviews</strong>: Mechanical engineers can see the latest software increments, and the software team learns about any upcoming mechanical changes.</p><p>• <strong>Joint Retrospectives</strong>: Identify what worked, what didn’t, and adapt together.</p><p><strong>3.4 Evolving Requirements Management</strong></p><p>• <strong>From Static Docs to a Living Backlog</strong>:</p><p>• Move away from a fixed “cahier des charges” to a backlog that includes both hardware and software needs.</p><p>• Implement a clear <strong>change management</strong> process: the instant mechanical specs shift, software adjustments are prioritized accordingly.</p><p><strong>3.5 Common Collaboration Tools</strong></p><p>• <strong>Shared Platforms</strong>: Use Jira, Confluence, or similar to keep <strong>everyone</strong> in the loop.</p><p>• <strong>Single Source of Truth</strong>: Centralize all specs, user stories, and designs so no one is caught off-guard.</p><p><strong>4. Why Bother? The (Massive) Payoff</strong></p><p>Bridging the gap between the V-model and Agile can significantly <strong>cut down on rework</strong> and <strong>prevent budget overruns</strong>. It also:</p><p>1. <strong>Minimizes Surprises</strong>: Fewer late-stage changes that require burning more budget.</p><p>2. <strong>Improves Product Quality</strong>: Both hardware and software align to deliver a cohesive solution.</p><p>3. <strong>Boosts Team Morale</strong>: People get frustrated when their work goes to waste; timely communication keeps rework low.</p><p>4. <strong>Protects the Bottom Line</strong>: Early and frequent collaboration can save millions on large-scale programs, given the hefty cost of late design changes.</p><h3>5. Final Thoughts</h3><p>My time in the automotive sector taught me that <strong>great products emerge when teams adapt and communicate frequently</strong>, especially in hardware-software combos. The V-model isn’t going away — nor should it, given safety and regulatory constraints. But a <strong>hybrid governance</strong> that respects rigorous validation needs while embracing the <strong>flexibility of Agile</strong> can be a game-changer.</p><p>If you’re facing a similar process clash or have found clever ways to blend V-model and Agile, I’d love to hear your thoughts. Let’s keep the conversation going and <strong>build better, more aligned products</strong> — on four wheels, two wheels, or in the cloud!</p><p><strong>References &amp; Further Reading</strong></p><p>1. <strong>Capers Jones</strong>: <em>Patterns of Software Systems Failure and Success</em></p><p>2. <strong>Standish Group</strong>: <em>Chaos Report</em> (Multiple editions)</p><p>3. <strong>INCOSE</strong>: <em>Systems Engineering Handbook</em> (latest edition)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31a623769c8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftUI is the accessibility game changer for Inclusive Apps]]></title>
            <link>https://medium.com/@aymen.chouirfi/swiftui-is-the-accessibility-game-changer-for-inclusive-apps-2ee048232d1f?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ee048232d1f</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[inclusive-design]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 07:52:54 GMT</pubDate>
            <atom:updated>2025-04-16T07:52:54.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y23NZu2ASzZavvxxM9RBOg.png" /><figcaption>Image generated using ChatGPT 4o</figcaption></figure><p>SwiftUI isn’t just about faster UI development — it also makes creating accessible apps way easier. Apple designed it with accessibility in mind, and with just a few lines of code, you can dramatically improve the experience for users who rely on assistive technologies like VoiceOver, Switch Control, or Dynamic Type</p><h4>1. Built-in Accessibility by Default</h4><ul><li>Buttons get VoiceOver labels, system images are described, and text respects dynamic type out of the box.</li><li><strong>No extra work</strong> for basic accessibility — that’s huge.</li></ul><p><em>Example: A Button automatically announces its label and trait to VoiceOver</em></p><pre>Button(&quot;Submit&quot;) {<br>    // action<br>}</pre><h4>2. .accessibilityLabel() and Friends</h4><p>Customizing accessibility is simple and expressive.</p><ul><li>accessibilityLabel(_:)</li><li>accessibilityHint(_:)</li><li>accessibilityValue(_:)</li><li>accessibilityHidden(_:)</li></ul><pre>Image(systemName: &quot;trash&quot;)<br>    .accessibilityLabel(&quot;Delete item&quot;)<br>    .accessibilityHint(&quot;Removes the item from your list&quot;)</pre><h4>3. Combine Views into a Single Element</h4><p>Using <strong>.accessibilityElement(children: .combine)</strong> helps group multiple views as one accessible item. This is perfect for composite UI.</p><pre>HStack {<br>    Image(systemName: &quot;star&quot;)<br>    Text(&quot;5 stars&quot;)<br>}<br>.accessibilityElement(children: .combine)</pre><h4>4. Custom Traits with .accessibilityAddTraits()</h4><p>SwiftUI supports traits like <strong>.isButton</strong>, <strong>.isHeader</strong>, <strong>.isSelected</strong>, etc., for more semantic clarity.</p><pre>Text(&quot;Top Stories&quot;)<br>    .accessibilityAddTraits(.isHeader)</pre><h4>5. Dynamic Type Support by Default</h4><ul><li>SwiftUI respects the user’s preferred text size without needing to do anything extra.</li><li>Using Text, Font, and ScaledMetric means your UI scales naturally.</li></ul><p><em>Pro Tip: Use </em><strong><em>@ScaledMetric</em></strong><em> for layout spacing:</em></p><pre>@ScaledMetric var iconWidth: CGFloat = 24<br> Image(systemName: &quot;heart&quot;)<br>     .resizable()<br>     .scaledToFit()<br>     .frame(width: min(max(38, iconWidth), 70)) </pre><h4>6. Accessibility Actions</h4><p>You can define custom actions that VoiceOver users can trigger.</p><pre>Image(systemName: &quot;heart&quot;)<br>    .accessibilityLabel(&quot;Favorite&quot;)<br>    .accessibilityAction(named: &quot;Favorite this item&quot;) {<br>        print(&quot;Favorited!&quot;)<br>    }</pre><h4>7. Accessibility Focus Management (iOS 15+)</h4><p>Programmatically shift focus for better UX with assistive tech.</p><pre>struct WelcomeView: View {<br>    @AccessibilityFocusState private var isFocused: Bool<br><br>    var body: some View {<br>        Text(&quot;Welcome!&quot;)<br>            .accessibilityFocused($isFocused)<br>            .onAppear {<br>                isFocused = true<br>            }<br>    }<br>}</pre><h4>8. Color and Contrast Awareness</h4><ul><li>SwiftUI encourages using semantic colors (like .label, .background) which adjust automatically for dark mode and accessibility contrast settings.</li><li>Use <strong>.accessibilityContrast(.increased</strong>) to detect user preference and adjust styling.</li></ul><pre>.environment(\.accessibilityContrast) { contrast in<br>    if contrast == .increased {<br>        // Adjust colors, borders, etc.<br>    }<br>}</pre><h4>9. VoiceOver Rotor and Sorting with .accessibilitySortPriority()</h4><p>Control how content is navigated with .accessibilitySortPriority() and traits to make content more discoverable.</p><pre>VStack {<br>    Text(&quot;Title&quot;)<br>        .accessibilitySortPriority(2)<br><br>    Text(&quot;Subtitle&quot;)<br>        .accessibilitySortPriority(1)<br>}</pre><h4>10. Live Previews in Xcode</h4><p>Use the <strong>Accessibility Inspector</strong> or <strong>VoiceOver + Simulator</strong> with SwiftUI Previews to test accessibility instantly — no build and run required.</p><h3>Conclusion</h3><p>SwiftUI empowers developers to build inclusive apps without extra complexity. With accessibility features baked right in and APIs that are intuitive to use, there’s no excuse not to make your app work beautifully for everyone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ee048232d1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Spotify (organization) Trap: Stop Forcing a One-Size-Fits-All Framework]]></title>
            <link>https://medium.com/@aymen.chouirfi/the-spotify-organization-trap-7b47a1b1c734?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b47a1b1c734</guid>
            <category><![CDATA[teams-and-teamwork]]></category>
            <category><![CDATA[organization]]></category>
            <category><![CDATA[management-and-leadership]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 10:53:07 GMT</pubDate>
            <atom:updated>2025-03-10T10:53:07.424Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pxf3MyGumjeW4Pd8" /></figure><p>The Spotify Model, renowned for its Squads, Tribes, Chapters, and Guilds, has become a go-to example of how to achieve agile at scale. Inspired by Spotify’s innovative culture and flexible structures, many organizations have tried to replicate the model in hopes of matching its success. However, hasty or superficial adoption often leads to more trouble than transformation. Here’s why blindly forcing the Spotify Model can be a trap — and what to do instead.</p><h3><strong>The Appeal of the Spotify Model</strong></h3><p>1. <strong>Autonomy and Collaboration</strong></p><p>The model’s core promise is that cross-functional teams (Squads) can operate with a high degree of independence while still aligning around broader goals within Tribes. Chapters and Guilds then facilitate knowledge sharing and a sense of community across the entire organization.</p><p>2. <strong>High-Profile Success</strong></p><p>Spotify’s rise to global prominence has made their organizational design the envy of many. Success stories and presentations often highlight the model’s best features but rarely dive into the complex cultural and operational dependencies that make it work.</p><h3><strong>Why the Model Falls Short</strong></h3><p>1. <strong>Autonomy and Collaboration</strong></p><p>The model’s core promise is that cross-functional teams (Squads) can operate with a high degree of independence while still aligning around broader goals within Tribes. Chapters and Guilds then facilitate knowledge sharing and a sense of community across the entire organization.</p><p>2. <strong>High-Profile Success</strong></p><p>Spotify’s rise to global prominence has made their organizational design the envy of many. Success stories and presentations often highlight the model’s best features but rarely dive into the complex cultural and operational dependencies that make it work.</p><h3><strong>Why the Model Falls Short</strong></h3><p>1. <strong>Cultural Misalignment</strong></p><p>The Spotify Model thrives in a culture that values experimentation, quick iteration, and open communication. If your organization operates with rigid hierarchies and punishes failure, you can’t expect teams to embrace autonomy and risk-taking overnight.</p><p>2. <strong>Size and Legacy Structures</strong></p><p>Spotify started small and iterated its organizational design as it grew. Companies with deep-rooted processes or sprawling legacy systems may find the model cumbersome or entirely mismatched to existing workflows.</p><p>3. <strong>Form Over Function</strong></p><p>At its core, the Spotify Model is about creating an environment for continuous improvement and customer-focused innovation. If you’re only replicating job titles and meeting cadences without deeply understanding or adopting these principles, you’ll likely end up with superficial changes and minimal impact.</p><p>4. <strong>The Static View of a Dynamic Model</strong></p><p>The published “Spotify Model” is already outdated in Spotify’s own evolution. Many companies cling to a snapshot in time — an approach that contradicts the very concept of agility, which requires ongoing iteration and adaptation</p><h3><strong>When It’s Not the Right Fit</strong></h3><p>• <strong>Risk-Averse or Traditional Organizations</strong></p><p>If your decision-making is centralized and your culture punishes failure, autonomy and rapid experimentation will be stifled.</p><p>• <strong>Highly Regulated Environments</strong></p><p>Strict regulatory requirements can constrain the freedoms that Squads need to move quickly, making the model less effective — or even impossible to implement.</p><p>• <strong>Very Small Teams</strong></p><p>A team of fewer than 10 people typically doesn’t need the layered structures of Squads, Tribes, and Chapters. Over-engineering the organization will only add bureaucracy.</p><p>• <strong>Non-Tech or Non-Product-Centric Companies</strong></p><p>The model emerged from a tech-driven, product-focused environment. Organizations whose primary work doesn’t revolve around product development might need a different approach.</p><h3><strong>What You Should Do Instead</strong></h3><p>1. <strong>Focus on Principles, Not Labels</strong></p><p>Before adopting structural changes, understand the core values behind the model — autonomy, mastery, and purpose. Apply these ideas in a way that aligns with your specific context and culture.</p><p>2. <strong>Assess Your Readiness</strong></p><p>Conduct a thorough evaluation of your existing processes, cultural norms, and skill sets. Figure out what you need to improve or change before making any structural shifts.</p><p>3. <strong>Iterate in Small Steps</strong></p><p>Don’t restructure your entire organization all at once. Experiment with small teams or pilot projects to see what works. Learn from those experiments, then refine your approach.</p><p>4. <strong>Combine Frameworks</strong></p><p>The Spotify Model isn’t the only agile framework out there. Draw on principles from Scrum, Kanban, Lean, or other methods. Craft a hybrid that fits your organizational DNA.</p><h3><strong>Conclusion</strong></h3><p>The Spotify Model can be an excellent source of inspiration, but applying it verbatim often does more harm than good. Without the right cultural foundation, supportive leadership, and readiness to iterate, replicating the structures of Squads, Tribes, Chapters, and Guilds won’t magically transform your teams. By understanding why the model works for Spotify — and where its limitations lie — you can avoid falling into the Spotify trap. Instead, focus on adopting and adapting principles in a way that resonates with your unique context, empowering your teams to create sustainable, meaningful change.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b47a1b1c734" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sealed and Secure : Foundations for Black-Box SDKs]]></title>
            <link>https://medium.com/@aymen.chouirfi/foundations-for-ios-black-box-sdks-3dbc300279a1?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dbc300279a1</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[sdk-development]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 08:11:33 GMT</pubDate>
            <atom:updated>2025-03-06T08:11:33.163Z</atom:updated>
            <content:encoded><![CDATA[<p>Discover essential foundation for building secure, high-performance Black-Box SDKs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jXIU5hBrwUxsHTIIyHaRg.png" /><figcaption>Image generated with DALL-E</figcaption></figure><h3>Introduction</h3><p>Building an SDK requires careful planning for <strong>modularity</strong>, <strong>efficiency</strong>, and <strong>security</strong>. For <strong>Black-Box SDK</strong>s, techniques like <strong>binary distribution</strong>, <strong>obfuscation</strong>, and <strong>runtime checks</strong> protect internal logic.</p><p>This article covers best practices for secure, high-performance SDK development. 🚀</p><h3>1. <strong>Versioning and Backward Compatibility</strong></h3><p>Following <strong>Semantic Versioning (SemVer)</strong> helps prevent breaking changes.</p><ul><li>1.0.0 (Major) → Breaking changes.</li><li>1.1.0 (Minor) → New features, backward compatible.</li><li>1.1.1 (Patch) → Bug fixes.</li></ul><p>Also<strong>, Deprecating APIs Gracefully </strong>helps <strong>notify SDK users</strong> while maintaining compatibility.</p><p>Example</p><pre>@available(*, deprecated, message: &quot;Use newMethod() instead.&quot;)<br>public func oldMethod() {<br>    print(&quot;This method is deprecated.&quot;)<br>}<br><br>public func newMethod() {<br>    print(&quot;Use this method instead.&quot;)<br>}</pre><h3>2. Documentation</h3><p>Apple’s <strong>DocC</strong> is the best way to generate <strong>developer-friendly, auto-generated documentation</strong> in Xcode. Below is a <strong>well-structured DocC documentation example</strong>, broken into multiple sections.</p><p><strong>2.1 Documenting the SDK Overview</strong></p><p>This is the <strong>high-level SDK documentation</strong>, explaining its purpose and usage.</p><pre>import Foundation<br><br>/// `MySDK` is a lightweight framework for fetching data securely.<br>///<br>/// # Features<br>/// - Secure API request handling.<br>/// - Customizable network manager.<br>/// - Supports async/await and completion handlers.<br>public class MySDK {<br>    /// Creates an instance of `MySDK`.<br>    ///<br>    /// - Returns: A new instance of `MySDK`.<br>    public init() {}<br>}</pre><p>This will generate rich, interactive documentation when you Option + Click<strong> </strong>(⌥ + Click)<strong> </strong>on the class or method in Xcode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7iZFNk_Nh67aMCq0Y-axow.png" /><figcaption>Generated Documentation inside Xcode</figcaption></figure><p><strong>2.2 Documenting public functions/components</strong></p><p>Each public method/component should have a <strong>detailed explanation</strong>, including <strong>parameters, return values, and examples</strong>.</p><pre>    /// Fetches data from a given URL securely.<br>    ///<br>    /// This method supports both async/await and completion handlers.<br>    ///<br>    /// - Parameter url: The URL to fetch data from.<br>    /// - Returns: The fetched `Data` from the server.<br>    /// - Throws: ``MySDKError``<br> <br>    public func fetchData(from url: URL?) async throws -&gt; Data {<br>        guard let url = url else { throw MySDKError.invalidURL }<br>        let (data, _) = try await URLSession.shared.data(from: url)<br>        return data<br>    }</pre><p><strong>[3] Documenting Error Handling</strong></p><p>Clearly document errors <strong>thrown by the SDK</strong>, ensuring developers know how to handle them.</p><pre>/// Represents possible errors in `MySDK`.<br>public enum MySDKError: Error {<br>    /// Indicates that the provided URL is invalid.<br>    case invalidURL<br>    ...<br>}</pre><h3>3. <strong>Modularity &amp; Architecture</strong></h3><p>When building an SDK, one common pitfall is <strong>creating a monolithic structure</strong> — where all functionalities are tightly coupled into a single framework.</p><p>the <strong>multi-product approach</strong> using <strong>Swift Package Manager (SPM)</strong> allows <strong>better modularization</strong>, enabling developers to integrate <strong>only the required components</strong></p><p>Example: <strong>AwesomeAnalyticsSDK</strong> Multi-Module Definition</p><pre>// swift-tools-version: 5.9<br>import PackageDescription<br><br>let package = Package(<br>    name: &quot;AwesomeAnalyticsSDK&quot;,<br>    platforms: [.iOS(.v13)],<br>    products: [<br>        .library(name: &quot;CoreAnalytics&quot;, targets: [&quot;CoreAnalytics&quot;]),<br>        .library(name: &quot;EventTracker&quot;, targets: [&quot;EventTracker&quot;])<br>    ],<br>    dependencies: [],<br>    targets: [<br>        .target(<br>            name: &quot;CoreAnalytics&quot;,<br>            dependencies: [&quot;EventTracker&quot;]<br>        ),<br>        .target(<br>            name: &quot;EventTracker&quot;,<br>            dependencies: [&quot;InternalLogger&quot;] // ✅ Internal module, NOT exposed externally<br>        ),<br>        .target(<br>            name: &quot;InternalLogger&quot;,  // ✅ Hidden from public use<br>            dependencies: []<br>        )<br>    ]<br>)</pre><p><strong>Package scope for better ACL</strong></p><p>The introduction of the <strong>package</strong> (<a href="https://github.com/swiftlang/swift-evolution/blob/main/proposals/0386-package-access-modifier.md">SE-0386</a> and <a href="https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md">SE-0409</a>) modifier fills a gap by allowing symbols to be shared across modules within the same package without exposing them to external clients. This is particularly useful when you want to organize your code into multiple modules for better modularity and separation of concerns but still need certain internal implementations to be shared across these modules.</p><p>This serves as a <strong>quick reference guide</strong> for Swift 5.9 <a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/accesscontrol/">ACL</a> levels.</p><pre>open class OpenClass {} <br>// ✅ Accessible from anywhere (including subclassing &amp; overriding outside the module)<br>public class PublicClass {} <br>// ✅ Accessible from anywhere within the module or external modules<br>package class PackageClass {} <br>// ✅ NEW: Accessible within the same Swift package but NOT outside<br>internal class InternalClass {} <br>// ✅ Default access level: Accessible within the same module<br>fileprivate class FilePrivateClass {} <br>// ✅ Accessible only within the same file<br>private class PrivateClass {} <br>// ✅ Accessible only within the same enclosing scope (e.g., class, struct, function)</pre><h3>4. SDK logging system</h3><p>A well-designed SDK should allow developers to <strong>enable or disable verbose logs</strong> at the time of initialization. This ensures <strong>better debugging capabilities</strong> while keeping logs disabled in production by default<strong>.</strong></p><p>Example</p><pre>let analytics = AwesomeAnalytics(enableVerboseLogging: true)</pre><h3>5. <strong>🔐 Security Enforcement in a Black-Box SDK</strong></h3><p>A <strong>Black-Box SDK</strong> must enforce <strong>runtime security checks</strong> to prevent <strong>tampering, debugging, and reverse engineering</strong>. By integrating a SecurityChecker directly into the SDK’s initializer, security validation occurs <strong>before execution</strong>, blocking usage on compromised devices. To maintain testability,</p><p>SecurityChecker is <strong>injected</strong> as a dependency, allowing developers to <strong>mock security checks</strong> in unit tests</p><pre>import Foundation<br><br>public class MySDK {<br>    private let securityChecker: SecurityChecker<br><br>    /// Internal initializer for dependency injection (used in tests).<br>    internal init(securityChecker: SecurityChecker = SecurityChecker()) throws {<br>        self.securityChecker = securityChecker<br>        try securityChecker.validate()  // 🚀 Security enforced at initialization<br>        print(&quot;✅ MySDK initialized successfully.&quot;)<br>    }<br><br>    /// Public initializer (used by SDK clients).<br>    public convenience init() throws {<br>        try self.init(securityChecker: SecurityChecker())<br>}</pre><p>Example of basic <strong>SecurityChecker</strong></p><pre>import Foundation<br>import UIKit<br><br>/// Typealias for a closure that checks for jailbreak status<br>typealias JailbreakChecker = () -&gt; Bool<br><br>/// Typealias for a closure that checks if a debugger is attached<br>typealias DebuggerAttachedChecker = () -&gt; Bool<br><br>struct SecurityChecker {<br>    private let jailbreakChecker: JailbreakChecker<br>    private let debuggerChecker: DebuggerAttachedChecker<br><br>    /// Initialize with dependency injection (default to real checks)<br>    public init(<br>        jailbreakChecker: @escaping JailbreakChecker = SecurityChecker.defaultJailbreakCheck,<br>        debuggerChecker: @escaping DebuggerAttachedChecker = SecurityChecker.defaultDebuggerCheck<br>    ) {<br>        self.jailbreakChecker = jailbreakChecker<br>        self.debuggerChecker = debuggerChecker<br>    }<br><br>    /// Run security checks and throw an error if a violation is detected<br>    public func validate() throws {<br>        if debuggerChecker() {<br>            throw SecurityError.debuggerDetected<br>        } else if jailbreakChecker() {<br>            throw SecurityError.jailbrokenDevice<br>        }<br>    }<br>}<br><br>// MARK: - Default Security Checks<br>private extension SecurityChecker {<br>    static func defaultDebuggerCheck() -&gt; Bool {<br>        var name = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]<br>        var info = kinfo_proc()<br>        var infoSize = MemoryLayout&lt;kinfo_proc&gt;.size<br><br>        let result = name.withUnsafeMutableBytes { namePointer -&gt; Int32 in<br>            guard let baseAddress = namePointer.baseAddress else { return -1 }<br>            return sysctl(baseAddress.assumingMemoryBound(to: Int32.self), 4, &amp;info, &amp;infoSize, nil, 0)<br>        }<br><br>        return result == 0 &amp;&amp; (info.kp_proc.p_flag &amp; P_TRACED) != 0<br>    }<br><br>    static func defaultJailbreakCheck() -&gt; Bool {<br>        #if targetEnvironment(simulator)<br>        return false<br>        #else<br>        let fileManager = FileManager.default<br>        let suspiciousPaths = [<br>            &quot;/Applications/Cydia.app&quot;,<br>            &quot;/Library/MobileSubstrate/MobileSubstrate.dylib&quot;,<br>            &quot;/bin/bash&quot;,<br>            &quot;/usr/sbin/sshd&quot;,<br>            &quot;/etc/apt&quot;<br>        ]<br><br>        for path in suspiciousPaths {<br>            if fileManager.fileExists(atPath: path) {<br>                return true<br>            }<br>        }<br><br>        if canOpenCydia() {<br>            return true<br>        }<br><br>        let testWritePath = &quot;/private/&quot; + UUID().uuidString<br>        do {<br>            try &quot;Test&quot;.write(toFile: testWritePath, atomically: true, encoding: .utf8)<br>            try fileManager.removeItem(atPath: testWritePath)<br>            return true<br>        } catch {<br>            return false<br>        }<br>        #endif<br>    }<br><br>    static func canOpenCydia() -&gt; Bool {<br>        guard let url = URL(string: &quot;cydia://package/com.example.package&quot;) else { return false }<br>        return UIApplication.shared.canOpenURL(url)<br>    }<br>}</pre><h3>6. <strong>Securely Distributing Black-Box SDK</strong></h3><p>Automating the <strong>distribution process</strong> for a <strong>Black-Box SDK</strong> ensures <strong>efficiency, security, and reliability</strong>. This script streamlines the entire workflow, making it easy to distribute any <strong>precompiled XCFramework</strong>.</p><p>It performs <strong>cleaning</strong>, <strong>building</strong>, <strong>symbol stripping</strong>, <strong>obfuscation</strong>, <strong>code signing</strong>, <strong>compression</strong>, and <strong>checksum generation,</strong> <a href="https://github.com/rockbruno/swiftshield"><strong>SwiftShield</strong></a><strong> for obfuscation</strong> and <strong>code signing </strong>— all in a single execution.</p><p>I’m sharing this fully commented script so you can <strong>use it for any Black-Box SDK distribution</strong>, ensuring a <strong>secure and automated release process</strong>.</p><pre>#!/bin/bash<br><br>SCRIPT_DIR=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)&quot; &amp;&amp; pwd)&quot;<br><br># Set SDK name<br>SDK_NAME=&quot;MySDK&quot;<br><br># Set output directories relative to the script location<br>BUILD_DIR=&quot;$SCRIPT_DIR/build&quot;<br>ARCHIVE_DIR=&quot;$BUILD_DIR/archives&quot;<br>XCFRAMEWORK_OUTPUT=&quot;$BUILD_DIR/$SDK_NAME.xcframework&quot;<br>ZIP_OUTPUT=&quot;$BUILD_DIR/$SDK_NAME.xcframework.zip&quot;<br><br># Set the signing identity (modify as needed)<br>SIGNING_IDENTITY=&quot;Developer ID Application&quot;<br><br># 🧹 Clean previous builds<br>clean_build() {<br>    echo &quot;🧹 Cleaning previous builds...&quot;<br>    rm -rf &quot;$BUILD_DIR&quot;<br>    mkdir -p &quot;$ARCHIVE_DIR&quot;<br>}<br><br># 🏗️ Build and archive the SDK for iOS devices<br>build_ios() {<br>    echo &quot;🚀 Building $SDK_NAME for iOS...&quot;<br>    xcodebuild archive \<br>      -scheme $SDK_NAME \<br>      -destination &quot;generic/platform=iOS&quot; \<br>      -archivePath &quot;$ARCHIVE_DIR/$SDK_NAME.framework-iphoneos.xcarchive&quot; \<br>      SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty<br>}<br><br># 📱 Build and archive the SDK for iOS Simulator<br>build_ios_simulator() {<br>    echo &quot;📱 Building $SDK_NAME for iOS Simulator...&quot;<br>    xcodebuild archive \<br>      -scheme $SDK_NAME \<br>      -destination &quot;generic/platform=iOS Simulator&quot; \<br>      -archivePath &quot;$ARCHIVE_DIR/$SDK_NAME.framework-iphonesimulator.xcarchive&quot; \<br>      SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty<br>}<br><br># 🔗 Create a universal XCFramework combining iOS and Simulator builds<br>create_xcframework() {<br>    echo &quot;📦 Creating XCFramework...&quot;<br>    xcodebuild -create-xcframework \<br>      -framework &quot;$ARCHIVE_DIR/$SDK_NAME.framework-iphoneos.xcarchive/Products/Library/Frameworks/$SDK_NAME.framework&quot; \<br>      -framework &quot;$ARCHIVE_DIR/$SDK_NAME.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/$SDK_NAME.framework&quot; \<br>      -output &quot;$XCFRAMEWORK_OUTPUT&quot;<br>}<br><br># 🔒 Strip symbols to remove method and class names<br>strip_symbols() {<br>    echo &quot;🔒 Stripping symbols to remove method and class names...&quot;<br>    find &quot;$XCFRAMEWORK_OUTPUT&quot; -name &quot;*.framework&quot; -exec strip -S -x {} \;<br>}<br><br># 🛡️ Obfuscate symbols using SwiftShield (Mandatory)<br>obfuscate_symbols() {<br>    if ! command -v swiftshield &amp;&gt; /dev/null<br>    then<br>        echo &quot;❌ SwiftShield not found. You must install it before proceeding.&quot;<br>        echo &quot;💡 Install it using: brew install swiftshield&quot;<br>        exit 1  # ❌ Fail the script<br>    fi<br><br>    echo &quot;🛡️ Obfuscating symbols with SwiftShield...&quot;<br>    swiftshield --input &quot;$XCFRAMEWORK_OUTPUT&quot; --output &quot;$XCFRAMEWORK_OUTPUT&quot;<br>}<br><br># 🔏 Code signing to prevent tampering<br>code_sign() {<br>    echo &quot;🔏 Code signing the XCFramework...&quot;<br>    codesign --force --deep --sign &quot;$SIGNING_IDENTITY&quot; &quot;$XCFRAMEWORK_OUTPUT&quot;<br>}<br><br># 📂 Zip the XCFramework for distribution<br>compress_xcframework() {<br>    echo &quot;🗜️ Compressing XCFramework...&quot;<br>    cd &quot;$BUILD_DIR&quot;<br>    zip -r &quot;$ZIP_OUTPUT&quot; &quot;$SDK_NAME.xcframework&quot;<br>}<br><br># 🔍 Compute checksum for Swift Package Manager integrity verification<br>generate_checksum() {<br>    echo &quot;🔢 Generating Checksum...&quot;<br>    CHECKSUM=$(swift package compute-checksum &quot;$ZIP_OUTPUT&quot;)<br>    echo &quot;Checksum: $CHECKSUM&quot;<br>}<br><br># 🚀 Main function to execute all steps in order<br>main() {<br>    clean_build<br>    build_ios<br>    build_ios_simulator<br>    create_xcframework<br>    strip_symbols<br>    obfuscate_symbols  # 🚀 Now fails if SwiftShield is missing<br>    code_sign          # 🚀 Ensures the framework is signed before distribution<br>    compress_xcframework<br>    generate_checksum<br><br>    # ✅ Final Success Messages<br>    echo &quot;✅ XCFramework successfully created at: $XCFRAMEWORK_OUTPUT&quot;<br>    echo &quot;✅ Compressed XCFramework: $ZIP_OUTPUT&quot;<br>    echo &quot;✅ Checksum: $CHECKSUM&quot;<br><br>    # 🚀 You can automate uploading to GitHub Releases or AWS S3 here<br>}<br><br># Run the script<br>main</pre><p>Your <strong>SPM package</strong> will reference the <strong>precompiled XCFramework</strong> generated by the script and uploaded somewhere ☁.</p><p>Since SPM supports <strong>binary frameworks</strong>, you can distribute your <strong>Black-Box SDK</strong> securely without exposing source code.</p><pre>// swift-tools-version: 6.0<br>import PackageDescription<br><br>let package = Package(<br>    name: &quot;MySDK&quot;,<br>    platforms: [.iOS(.v16)],<br>    products: [<br>        .library(name: &quot;MySDK&quot;, targets: [&quot;MySDK&quot;])<br>    ],<br>    targets: [<br>        .binaryTarget(<br>            name: &quot;MySDK&quot;,<br>            url: &quot;YOUR_ZIP_URL&quot;,<br>            checksum: &quot;YOUR_GENERATED_CHECKSUM_HERE&quot;<br>        )<br>    ]<br>)</pre><h3><strong>Final Thoughts</strong></h3><p>A <strong>Black-Box SDK</strong> is more than just a hidden implementation — it’s a <strong>secure, structured, and efficient</strong> solution that balances protection and usability. With <strong>modular architecture</strong>, strong <strong>security enforcement</strong>, and <strong>automated distribution</strong>, you ensure that your SDK remains <strong>reliable, maintainable, and resistant to reverse engineering</strong>. By following these best practices, you create an SDK that is <strong>future-proof, scalable, and effortless to integrate</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dbc300279a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hey, Managers: Offboarding Matters Too!]]></title>
            <link>https://medium.com/@aymen.chouirfi/offboarding-matters-too-efed60b09f44?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/efed60b09f44</guid>
            <category><![CDATA[hr-process]]></category>
            <category><![CDATA[manager]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[management]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 09:39:14 GMT</pubDate>
            <atom:updated>2025-02-17T09:39:14.908Z</atom:updated>
            <content:encoded><![CDATA[<p>Offboarding — how you handle an employee’s final days and departure — often gets overshadowed by onboarding. Yet many experts argue that offboarding can have a powerful impact on your organization’s culture, reputation, and knowledge retention. Below is a concise overview of why offboarding matters, supported by key insights from well-regarded books and articles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-wWoD6aKZlLl4TGh84png.png" /><figcaption>Image generated with DALL-E</figcaption></figure><h3><strong>Hey, Managers: Offboarding Matters Too! 👋</strong></h3><p>Offboarding — how you handle an employee’s final days — often gets overshadowed by onboarding. Yet many experts argue that offboarding has a big impact on your organization’s culture, reputation, and knowledge retention. Below is a concise overview of why offboarding matters, supported by insights from respected books and articles (with a few emojis thrown in for good measure).</p><h3><strong>Why Offboarding is so important?</strong></h3><p>1. <strong>Protects your brand reputation 🚀</strong></p><p>Departing employees often share their final impressions — whether online or in person. Research suggests that a well-structured, respectful offboarding process helps protect your brand. If you treat people well on their way out, they’re far more likely to speak positively about your organization to others..</p><p>2. <strong>Captures institutional knowledge 📚</strong></p><p>Each role includes routines that go beyond any official handbook. According to Reid Hoffman, Ben Casnocha, and Chris Yeh in <em>The Alliance</em>, companies excel when they handle the “tour of duty” concept thoroughly — including a robust handoff at the end. Documenting procedures, contact lists, and project statuses helps you keep critical expertise in-house.</p><p>3. <strong>Boosts team morale 💪</strong></p><p>How an organization treats departing employees signals its values to the remaining workforce. Empathetic offboarding shows that the company respects people — even if they choose to move on — leading to a more trusting and supportive environment.</p><p>4. <strong>Provides honest feedback 🔎</strong></p><p>Departing employees are often more open about the company’s strengths and weaknesses. In <em>Radical Candor</em>, Kim Scott emphasizes the importance of direct, caring communication. Offboarding is a great time to listen to unfiltered feedback that could spark positive change — if you’re prepared to respond constructively.</p><p>5. <strong>Sets the stage for future collaboration 🌐</strong></p><p>Departure doesn’t always mean goodbye forever. As the authors of <em>The Alliance</em> note, former employees might return, partner with your company later, or refer excellent candidates. A respectful offboarding process keeps the door open for these long-term opportunities.</p><h3><strong>Key Steps for Effective Offboarding</strong></h3><p>1. <strong>Communicate early and clearly 📣</strong></p><p>When someone announces (or learns of) their departure, clarify responsibilities, timelines, and next steps right away. Keeping everyone informed — HR, IT, direct managers — prevents confusion and helps transfer knowledge quickly.</p><p>2. <strong>Use a knowledge transfer checklist ✅</strong></p><p>Encourage the outgoing employee to document workflows, important contacts, and project statuses. Digital tools like Trello or SharePoint can keep this information organized and easily accessible.</p><p>3. <strong>Conduct a thoughtful exit interview 💬</strong></p><p>Don’t let exit interviews be a formality. Ask open-ended questions to uncover real insights:</p><p>• What motivated you to look elsewhere?</p><p>• What were the best parts of working here?</p><p>• How can we improve?</p><p>This approach echoes the “<a href="https://www.radicalcandor.com/">Radical Candor</a>” principle — genuine listening can yield transformative feedback.</p><p>4. <strong>Show appreciation 👏</strong></p><p>A heartfelt thank-you note or a small send-off can significantly shape how someone remembers their time at your company. A little recognition goes a long way toward preserving goodwill.</p><p>5. <strong>Stay in touch 🤝</strong></p><p>Connect on LinkedIn or send a quick “thank you” email after their final day. According to <a href="https://www.amazon.com/Alliance-Managing-Talent-Networked-Age/dp/1625275773"><em>The Alliance</em></a>, ongoing professional relationships can be mutually beneficial, especially in today’s interconnected job market.</p><h3><strong>Conclusion</strong></h3><p>Offboarding is more than an administrative task — it’s a strategic phase in the employee lifecycle. By handling departures with clarity, empathy, and genuine interest in feedback, you protect your brand, preserve knowledge, and maintain strong relationships.</p><p>Whether it’s gathering unfiltered insights (as Kim Scott champions in <a href="https://www.radicalcandor.com/"><em>Radical Candor</em></a> 🔑) or setting the stage for future collaborations (as advocated in <em>The Alliance</em> 🤝), offboarding can have lasting benefits for everyone involved. So, remember: onboarding may set the tone, but offboarding can truly define your organization’s reputation — one respectful farewell at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efed60b09f44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SPM Plugins: The Underrated powerhouse of Swift Development Ecosystem]]></title>
            <link>https://medium.com/@aymen.chouirfi/spm-plugins-242cdd9745d3?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/242cdd9745d3</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-package-plugins]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-package-manager]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 09:46:23 GMT</pubDate>
            <atom:updated>2025-02-10T09:46:23.899Z</atom:updated>
            <content:encoded><![CDATA[<p>From code generation to custom workflows: Discover why SPM Plugins deserve Your Attention</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXx6BNMqMZD0WaEL7eSsbw.png" /><figcaption>Image from Medium: hasancanakgunduz</figcaption></figure><h3>Introduction</h3><p>In the world of Swift, developers are always on the lookout for ways to enhance modularity, boost performance, and streamline their codebases. Yet, hidden in plain sight, SPM Plugins remain one of the most underrated tools in the Swift ecosystem. Despite their low profile, SPM Plugins offer a wealth of potential for advanced use cases, from code generation to custom build processes and runtime behavior customization.</p><p>This article delves into the intricacies of SPM Plugins, revealing how they work, why they’re powerful, and how you can leverage them to take your Swift development to the next level.</p><h3>Command Plugins VS Build Tool Plugins</h3><p>To create a SPM plugin, you have 2 options:</p><ul><li><strong>Build Tool Plugins</strong>: These integrate directly into the build process, automatically executing tasks such as code generation or resource processing during the build. They operate within a sandboxed environment with restricted permissions.</li><li><strong>Command Plugins</strong>: These are manually invoked to perform tasks like code formatting or linting. They can request permission to modify your package’s files and are typically used to enhance the development workflow.</li></ul><h3>1. Building your first BuildTool Plugin</h3><h4>1.1 Create a Plugin Package</h4><p>To create a Plugin, start by initializing a new SPM package:</p><p>swift package init --type plugin</p><p>This command creates a package with the following structure:</p><pre>MyPackage/<br>├── Package.swift<br>├── Plugins/<br>│   └── MyPlugin.swift  </pre><p>You can also manually create the file structure.</p><h4>1.2 Define the Plugin in MyPlugin.swift</h4><p>Here’s a basic example of a plugin that generates Swift code:</p><pre>import PackagePlugin<br><br>@main<br>struct CodeGeneratorPlugin: BuildToolPlugin {<br>    func createBuildCommands(context: PluginContext, target: Target) throws -&gt; [Command] {<br>        let inputPath = context.package.directory.appending(&quot;config.json&quot;)<br>        let outputPath = context.pluginWorkDirectory.appending(&quot;Generated.swift&quot;)<br><br>        return [<br>            .buildCommand(<br>                displayName: &quot;Generating Swift code from JSON&quot;,<br>                executable: URL(fileURLWithPath: &quot;/usr/bin/python3&quot;),<br>                arguments: [&quot;Scripts/code_generator.py&quot;, inputPath.string, outputPath.string],<br>                inputFiles: [inputPath],<br>                outputFiles: [outputPath]<br>            )<br>        ]<br>    }<br>}</pre><p>This plugin uses a Python script to process a JSON file (config.json) and output a generated Swift file (Generated.swift).</p><h4>1.3 Add the CodeGeneratorPlugin plugin in the target</h4><pre>dependencies: [<br>    .package(path: &quot;../MyPlugin&quot;)<br>],<br>targets: [<br>    .target(<br>        name: &quot;MyApp&quot;,<br>        plugins: [<br>            .plugin(name: &quot;CodeGeneratorPlugin&quot;, package: &quot;MyPlugin&quot;)<br>        ]<br>    )<br>]</pre><p>Run the build process, and the plugin will execute, generating the <strong>Generated.swift </strong>file as specified.</p><h4>1.4 Advanced example: Dynamic Configuration Injection</h4><pre>import PackagePlugin<br><br>@main<br>struct EnvironmentConfiguratorPlugin: BuildToolPlugin {<br>    func createBuildCommands(context: PluginContext, target: Target) throws -&gt; [Command] {<br>        let env = ProcessInfo.processInfo.environment[&quot;BUILD_ENV&quot;] ?? &quot;debug&quot;<br>        let configPath = context.package.directory.appending(&quot;configs/\(env).json&quot;)<br>        let outputPath = context.pluginWorkDirectory.appending(&quot;EnvironmentConfig.swift&quot;)<br><br>        return [<br>            .buildCommand(<br>                displayName: &quot;Generating Environment Config for \(env)&quot;,<br>                executable: URL(fileURLWithPath: &quot;/usr/bin/env&quot;),<br>                arguments: [&quot;python3&quot;, &quot;generate_config.py&quot;, configPath.string, outputPath.string],<br>                inputFiles: [configPath],<br>                outputFiles: [outputPath]<br>            )<br>        ]<br>    }<br>}</pre><p>In this example, the plugin reads an environment variable (<strong>BUILD_ENV</strong>) and selects the appropriate configuration file to generate an environment-specific Swift file</p><h3>2. Building your first Command Plugin</h3><h4>2.1 Create a Command Plugin</h4><p>Using the same structure as Build Tool Plugin, we create a new command Plugin</p><pre>MyPackageSPM/<br>├── Package.swift<br>├── Plugins/<br>│   └── MyCustomCommand.swift</pre><p>Here’s a basic example:</p><pre>import PackagePlugin<br><br>@main<br>struct MyCustomCommand: CommandPlugin {<br>    func performCommand(context: PluginContext, arguments: [String]) throws {<br>        // Your custom command implementation<br>    }<br>}</pre><h4>2.2 Declare your plugin capabilities</h4><p>In your package’s Package.swift manifest, define the plugin and specify its capabilities. For a command plugin, you can provide a custom verb and description that will appear in Xcode’s context menu.</p><pre>// swift-tools-version: 6.0<br>import PackageDescription<br><br>let package = Package(<br>    name: &quot;MyPackage&quot;,<br>    products: [<br>        .plugin(name: &quot;MyCustomCommand&quot;, targets: [&quot;MyCustomCommand&quot;])<br>    ],<br>    targets: [<br>        .plugin(<br>            name: &quot;MyCustomCommand&quot;,<br>            capability: .command(<br>                intent: .custom(<br>                    verb: &quot;my-custom-command&quot;,<br>                    description: &quot;Description of what your command does&quot;<br>                )<br>            ),<br>            path: &quot;Plugins/MyCustomCommand&quot;<br>        )<br>    ]<br>)</pre><h4>2.3 Integrate and Use the Plugin in Xcode</h4><ul><li>Open your project in Xcode.</li><li>Ensure your package is added to the project.</li><li>Right-click (Control-click) on the package or target in the Project Navigator.</li><li>You should see your custom command listed in the context menu. Selecting it will execute the plugin’s defined actions.</li></ul><h4>2.4 Advanced example: Format your code with SPM command</h4><ol><li><strong>Create a package including these dependancies</strong></li></ol><pre>// swift-tools-version: 6.0<br>import PackageDescription<br>sw<br>let package = Package(<br>    name: &quot;MyFormatterPlugin&quot;,<br>    products: [<br>        .plugin(name: &quot;FormatPlugin&quot;, targets: [&quot;FormatPlugin&quot;]),<br>    ],<br>    dependencies: [<br>        .package(url: &quot;https://github.com/nicklockwood/SwiftFormat&quot;, from: &quot;0.50.4&quot;),<br>    ],<br>    targets: [<br>        .plugin(<br>            name: &quot;SwiftFormat&quot;,<br>            capability: .command(<br>                intent: .sourceCodeFormatting(),<br>                permissions: [<br>                    .writeToPackageDirectory(reason: &quot;This command formats the Swift source files&quot;)<br>                ]<br>            ),<br>            dependencies: [<br>                .product(name: &quot;swiftformat&quot;, package: &quot;SwiftFormat&quot;),<br>            ]<br>        ),<br>    ]<br>)</pre><p>2. <strong>Implement the Plugin logic</strong></p><pre>import PackagePlugin<br>import Foundation<br><br>@main<br>struct FormatPlugin: CommandPlugin {<br>    func performCommand(context: PluginContext, arguments: [String]) throws {<br>        let tool = try context.tool(named: &quot;swiftformat&quot;)<br>        let toolURL = URL(fileURLWithPath: tool.path.string)<br>        for target in context.package.targets {<br>            guard let target = target as? SourceModuleTarget else { continue }<br>            let process = Process()<br>            process.executableURL = toolURL<br>            process.arguments = [target.directory.string]<br>            try process.run()<br>            process.waitUntilExit()<br>            if process.terminationStatus == 0 {<br>                print(&quot;Formatted source code in \(target.directory).&quot;)<br>            } else {<br>                Diagnostics.error(&quot;SwiftFormat failed for \(target.directory).&quot;)<br>            }<br>        }<br>    }<br>}</pre><p>3. Then, you can format your code by a simple right click</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qZgHS4otsEwpEc7-FxbGtA.gif" /></figure><h3><strong>Conclusion</strong></h3><p>SPM Plugins are a hidden gem in the Swift ecosystem, offering powerful tools to streamline workflows and automate tasks. From <strong>Build Tool Plugins</strong> for tasks like code generation to <strong>Command Plugins</strong> for actions like formatting, they provide flexibility to enhance your development process.</p><p>By mastering SPM Plugins, you can optimize your projects, automate repetitive tasks, and boost productivity. Don’t overlook their potential — start exploring and take your Swift development to the next level!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=242cdd9745d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thinking Outside the Apple  Box: SwiftUI Navigation Inspired by JS Routers (Part 3/3)]]></title>
            <link>https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-3-3-ef9e91f85892?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef9e91f85892</guid>
            <category><![CDATA[swift-6]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 09:50:54 GMT</pubDate>
            <atom:updated>2025-01-13T09:53:08.978Z</atom:updated>
            <content:encoded><![CDATA[<p>Reimagining SwiftUI Navigation with JS Router Concepts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQq_lqcBKnNbCpRvb7IF9g.png" /></figure><h4>Introduction</h4><p>In our <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-1-3-90f17648b72a">first article</a>, we built a simple yet effective <strong>Router</strong> designed for single-flow applications. Then, we took things up a notch in this <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-2-3-4d3480fb7017">article</a>, transforming our Router into a versatile tool capable of managing complex multi-flow setups.</p><p>Now, it’s time to push the boundaries even further!</p><p>In this article, we’ll evolve our implementation to seamlessly integrate into large, modular applications while meeting the sendability requirements of Swift 6.</p><h4>Make it Sendable !</h4><p>First, we will define a <strong>Route</strong> protocol to replace the use of <strong>Any</strong> in our Router implementation.</p><blockquote>Using <strong>Any</strong> compromises type safety and clarity, making code harder to maintain. A <strong>Route</strong> protocol ensures clear, type-safe interactions, enhancing both reliability and readability.</blockquote><pre>public protocol Route: Hashable, Sendable {}</pre><p>Updating our <strong>Router</strong> implementation</p><pre>enum RouterAction: Sendable {<br>    case push(any Route)<br>    case unwind<br>    case popToRoot<br>}<br><br>struct Router&lt;RouteType: Route&gt;: Sendable {<br>    typealias Action = @Sendable (RouterAction) -&gt; ()<br>    private let performAction: Action<br><br>    init(action: @escaping Action) {<br>        self.performAction = action<br>    }<br><br>    func perform(_ action: RouterAction) {<br>        switch action {<br>            case .push(let route):<br>                if let route = route as? RouteType {<br>                    performAction(.push(route))<br>                } else {<br>                    assertionFailure(<br>                        &quot;Type mismatch: Expected \(RouteType.self), got \(type(of: route))&quot;<br>                    )<br>                }<br>            case .unwind:<br>                performAction(.unwind)<br>            case .popToRoot:<br>                performAction(.popToRoot)<br>        }<br>    }<br><br>    var eraseToAnyRouter: AnyRouter {<br>        AnyRouter { anyAction in<br>            switch anyAction {<br>                case .push(let anyRoute):<br>                    if let route = anyRoute as? RouteType {<br>                        self.perform(.push(route))<br>                    } else {<br>                        assertionFailure(<br>                            &quot;Type mismatch: Expected \(RouteType.self), got \(type(of: anyRoute))&quot;<br>                        )<br>                    }<br>                case .unwind:<br>                    self.perform(.unwind)<br>                case .popToRoot:<br>                    self.perform(.popToRoot)<br>            }<br>        }<br>    }<br>}</pre><p>Now, we can mark our type-erased <strong>AnyRouter</strong> as <strong>Sendable</strong>.</p><pre>struct AnyRouter: Sendable {<br><br>    private let performAction: @Sendable (RouterAction) -&gt; ()<br><br>    init(_ action: @Sendable @escaping (RouterAction) -&gt; ()) {<br>        self.performAction = action<br>    }<br><br>    func perform(_ action: RouterAction) {<br>        performAction(action)<br>    }<br><br>    public func callAsFunction(_ action: RouterAction) {<br>        performAction(action)<br>    }<br>}</pre><p>Finally, we need to update our extension and modifier to align with these new requirements.</p><pre>extension EnvironmentValues {<br>    @Entry var navigate: AnyRouter = AnyRouter { _ in }<br>}<br><br>struct RouteEnvironmentModifier&lt;RouteType: Route&gt;: ViewModifier {<br><br>    @Binding var routes: [RouteType]<br><br>    func body(content: Content) -&gt; some View {<br>        content.environment(<br>            \.navigate,<br>             Router&lt;RouteType&gt; { action in<br>                 Task { @MainActor in<br>                     performNavigation(action)<br>                 }<br>             }.eraseToAnyRouter<br>        )<br>    }<br><br>    // MARK: - Private<br><br>    private func performNavigation(_ action: RouterAction) {<br>        switch action {<br>            case .push(let route):<br>                if let route = route as? RouteType {<br>                    routes.append(route)<br>                } else {<br>                    assertionFailure(<br>                        &quot;Type mismatch: Expected \(RouteType.self), got \(type(of: route))&quot;<br>                    )<br>                }<br>            case .unwind:<br>                if !routes.isEmpty {<br>                    routes.removeLast()<br>                }<br>            case .popToRoot:<br>                routes.removeAll()<br>        }<br>    }<br>}<br><br>extension NavigationStack {<br>    func withRoutes&lt;RouteType: Route&gt;(_ routes: Binding&lt;[RouteType]&gt;) -&gt; some View {<br>        self.modifier(RouteEnvironmentModifier(routes: routes))<br>    }<br>}</pre><h4><strong>Ensuring Route Consistency Throughout Navigation</strong></h4><p>You may have noticed that I added a few assertionFailure checks in our implementation to ensure the consistency of navigation routes.</p><p>For instance, if you initialize your <strong>NavigationStack</strong> with routes of type <strong>SquadRoute</strong> and accidentally attempt to navigate using a different route type, the application will crash.</p><pre>public struct SquadNavigationStack: View {<br>    <br>    @State private var routes: [SquadRoute] = []<br><br>    public var body: some View {<br>        NavigationStack(path: $routes) {<br>            SquadHomeScreen()<br>                .navigationDestination(for: SquadRoute.self) { route in<br>                    route.destination<br>                }<br>        }<br>        .withRoutes($routes)<br>    }<br>}<br><br>enum OtherRouteType: Route {<br>    case list<br>}<br><br>struct SquadHomeScreen: View {<br>    @Environment(\.navigate) private var navigate<br>    var body: some View {<br>        Button(&quot;Go to squad list screen&quot;) {<br>            navigate(.push(OtherRouteType.list)) // this will crash<br>        }<br>    }<br>}</pre><h4>Integration with micro-apps/modular architecture</h4><p>If we aim to create a standalone module or package for our <strong>Router</strong>, it is essential to carefully design the access control of the <strong>Router</strong>’s components to ensure proper encapsulation and usability.</p><ul><li><strong>Public components</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZP5bpeffLj5Ivh3D2hDJiA.png" /></figure><ul><li><strong>Internal components</strong></li></ul><p>The <strong>Router</strong> implementation and <strong>RouteEnvironmentModifier</strong> will remain internal to hide the implementation details from consumers.</p><h4>Create Router package within SPM</h4><p>In Xcode, navigate to <strong>File &gt; New &gt; Package…</strong> to create the Router Swift Package (SPM).</p><p>Similarly, in Xcode, go to <strong>File &gt; New &gt; Package…</strong> to create the <strong>Squad</strong> and <strong>Project</strong> packages.</p><p>We will end up with the following configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DxA5YH-u3dMJs5LcmVjO1w.png" /></figure><p>To integrate the <strong>Router</strong> into feature packages like Squad and Project views, it needs to be imported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDFXbR_QbMhJyUb3GMuRxg.png" /></figure><p>The main target does not need to import the <strong>Router</strong> module because each feature package handles its own navigation independently.</p><h4><strong>Access control for feature packages</strong></h4><p>To achieve better encapsulation in our architecture, only the main flow of each package will be exposed as public.</p><p>Following the example of <strong>Squad</strong> and <strong>Project</strong> introduced in Part 2 of this series, only <strong>SquadNavigationStack</strong> and <strong>ProjectNavigationStack</strong> will be public, while all other views will remain internal to their respective packages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfaYfV9NTNUxtANbAJ0X8A.png" /></figure><p>Now, we can link the feature packages to the main target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U9jVREfMbV3t2L6S2nlSYA.png" /></figure><p>Finally, we need to import the <strong>Squad</strong> and <strong>Project</strong> modules to resolve compiler issues.</p><p>Here is the updated code</p><pre>import SwiftUI<br>import Squad<br>import Project<br><br>enum TabBarItem: Hashable, Identifiable, CaseIterable {<br>    case project<br>    case squad<br>    var id: TabBarItem { self }<br>}<br><br>struct ContentView: View {<br>    @Binding var selection: TabBarItem?<br>    var body: some View {<br>        TabView(selection: $selection) {<br>            ForEach(TabBarItem.allCases) { screen in<br>                screen.destination<br>                    .tag(screen as TabBarItem?)<br>                    .tabItem { screen.label }<br>            }<br>        }<br>    }<br>}<br><br>extension TabBarItem {<br>    @ViewBuilder<br>    var label: some View {<br>        switch self {<br>            case .squad:<br>                Label(&quot;Squad&quot;, systemImage: &quot;person.3&quot;)<br>            case .project:<br>                Label(&quot;Project&quot;, systemImage: &quot;folder&quot;)<br>        }<br>    }<br><br>    @ViewBuilder<br>    var destination: some View {<br>        switch self {<br>            case .squad:<br>                SquadNavigationStack()<br>            case .project:<br>                ProjectNavigationStack()<br>        }<br>    }<br>}<br><br><br>@available(iOS 17.0, *)<br>#Preview {<br>    @Previewable @State var selection: TabBarItem? = .project<br>    ContentView(selection: $selection)<br>}</pre><h4>Conclusion</h4><p>Throughout this 3-part series (<a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-1-3-90f17648b72a">Part 1</a>, <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-2-3-4d3480fb7017">Part 2</a>, and <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-3-3-ef9e91f85892">Part 3</a>), I have aimed to share my iterative approach to building a programmatic navigation system designed to meet the needs of modularity and scalability. This approach focuses on creating a clean, maintainable architecture where navigation flows are encapsulated within individual feature modules while ensuring seamless integration with the main application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef9e91f85892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thinking Outside the Apple  Box: SwiftUI Navigation Inspired by JS Routers (Part 2/3)]]></title>
            <link>https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-2-3-4d3480fb7017?source=rss-aea86ab24796------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d3480fb7017</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift-6]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Aymen Chouirfi]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 09:48:10 GMT</pubDate>
            <atom:updated>2025-01-13T09:54:56.249Z</atom:updated>
            <content:encoded><![CDATA[<p>Reimagining SwiftUI Navigation with JS Router Concepts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQq_lqcBKnNbCpRvb7IF9g.png" /></figure><h4><strong>Introduction</strong></h4><p>In our <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-1-3-90f17648b72a">previous article</a>, we set up a simple and effective routing solution tailored for single-flow applications. Now, we’re taking it a step further, adapting this solution to support the flexibility and complexity of multi-flow applications and even micro-app architectures. Let’s dive in and see how we can elevate our approach to meet these new challenges.</p><h4><strong>Support Multi-Flow</strong></h4><p>Let’s assume our application includes a tab bar with two tabs: Squad and Project, where each tab manages its own flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oIVbaKYZm3AVqu01GMiXhg.png" /><figcaption>Multiple Flow</figcaption></figure><p>Then we have make our <strong>Router</strong> more generic to support multiple routes</p><pre>enum RouterAction&lt;RouteType&gt; {<br>    case push(RouteType)<br>    case unwind<br>    case popToRoot<br>}<br><br>struct Router&lt;RouteType&gt; {<br>    typealias Action = (RouterAction&lt;RouteType&gt;) -&gt; Void<br>    let performAction: Action<br><br>    init(action: @escaping Action) {<br>        self.performAction = action<br>    }<br><br>    func perform(_ action: RouterAction&lt;RouteType&gt;) {<br>        performAction(action)<br>    }<br>}</pre><p>Are We Done? Not Quite! If it were that simple, I wouldn’t be writing an article about it! 😅</p><p>The compiler isn’t too happy about this approach because we need to specify the route types for our router right when declaring them in the environment variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pUJyJv9IVqyXbcUxcBQVQ.png" /><figcaption>Swift Compiler is not happy</figcaption></figure><p>No worries — there’s a well-known solution for this well-known problem!</p><h4><strong>Type-Erasure to the Rescue</strong></h4><p>If you’ve used Apple’s Combine framework, you’re probably familiar with the <a href="https://developer.apple.com/documentation/combine/just/erasetoanypublisher()">eraseToAnyPublisher()</a> function. We’ll apply a similar type-erasure principle here.</p><p>Let’s start by implementing our AnyRouter</p><pre>public struct AnyRouter {<br>    private let performAction: (Any) -&gt; Void<br>    <br>    init(_ action: @escaping (Any) -&gt; Void) {<br>        self.performAction = action<br>    }<br><br>    func callAsFunction&lt;Action&gt;(_ action: Action) {<br>        performAction(action)<br>    }<br>}</pre><p>and make our compiler happy 🎉</p><pre>extension EnvironmentValues {<br>    @Entry var navigate: AnyRouter = AnyRouter { _ in }<br>}</pre><pre>struct Router&lt;RouteType&gt; {<br>    typealias Action = (RouterAction&lt;RouteType&gt;) -&gt; Void<br>    let performAction: Action<br><br>    init(action: @escaping Action) {<br>        self.performAction = action<br>    }<br><br>    func perform(_ action: RouterAction&lt;RouteType&gt;) {<br>        performAction(action)<br>    }<br><br>    var eraseToAnyRouter: AnyRouter {<br>        AnyRouter { action in<br>            if let action = action as? RouterAction&lt;RouteType&gt; {<br>                self.perform(action)<br>            } else {<br>                assertionFailure(&quot;Invalid action type&quot;)<br>            }<br>        }<br>    }<br>}<br><br>struct RouteEnvironmentModifier&lt;RouteType&gt;: ViewModifier {<br>    @Binding var routes: [RouteType]<br><br>    func body(content: Content) -&gt; some View {<br>        content.environment(<br>            \.navigate,<br>            Router&lt;RouteType&gt; { action in<br>                switch action {<br>                case .push(let route):<br>                    routes.append(route)<br>                case .unwind:<br>                    if !routes.isEmpty {<br>                        routes.removeLast()<br>                    }<br>                case .popToRoot:<br>                    routes.removeAll()<br>                }<br>            }.eraseToAnyRouter<br>        )<br>    }<br>}<br><br>extension View {<br>    func withRoutes&lt;RouteType&gt;(_ routes: Binding&lt;[RouteType]&gt;) -&gt; some View {<br>        self.modifier(RouteEnvironmentModifier(routes: routes))<br>    }<br>}</pre><h4>Let’s integrate our Router in a multi-flow application</h4><p>This is a basic implementation of TabView based application</p><pre>enum TabBarItem: Hashable, Identifiable, CaseIterable {<br>    case project<br>    case squad<br>    var id: TabBarItem { self }<br>}<br><br>struct ContentView: View {<br>    @Binding var selection: TabBarItem?<br>    var body: some View {<br>        TabView(selection: $selection) {<br>            ForEach(TabBarItem.allCases) { screen in<br>                screen.destination<br>                    .tag(screen as TabBarItem?)<br>                    .tabItem { screen.label }<br>            }<br>        }<br>    }<br>}<br><br>extension TabBarItem {<br>    @ViewBuilder<br>    var label: some View {<br>        switch self {<br>            case .squad:<br>                Label(&quot;Squad&quot;, systemImage: &quot;person.3&quot;)<br>            case .project:<br>                Label(&quot;Project&quot;, systemImage: &quot;folder&quot;)<br>        }<br>    }<br><br>    @ViewBuilder<br>    var destination: some View {<br>        switch self {<br>            case .squad:<br>                Text(&quot;Squad flow&quot;)<br>            case .project:<br>                Text(&quot;Project flow&quot;)<br>        }<br>    }<br>}</pre><h4>Squad flow integration</h4><p>Creating necessary views for Squad flow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPvXW-rg3PiF7NW_hr7lcw.png" /><figcaption>Squad flow views</figcaption></figure><p>Now, we will extend our enum <strong>SquadRoute</strong> and create our <strong>SquadNavigationStack</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EahhoONVBhFbTjKqUew0uQ.png" /></figure><p>Same thing for <strong>ProjectNavigationStack</strong></p><p>Now, let’s update our <strong>TabView</strong> implementation</p><pre>extension TabBarItem {<br>    @ViewBuilder<br>    var label: some View {<br>        switch self {<br>            case .squad:<br>                Label(&quot;Squad&quot;, systemImage: &quot;person.3&quot;)<br>            case .project:<br>                Label(&quot;Project&quot;, systemImage: &quot;folder&quot;)<br>        }<br>    }<br><br>    @ViewBuilder<br>    var destination: some View {<br>        switch self {<br>            case .squad:<br>                SquadNavigationStack()<br>            case .project:<br>                ProjectNavigationStack()<br>        }<br>    }<br>}</pre><h4>Demo time 🎥</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*8BEb79Oi_1HID-I7Uu1GgQ.gif" /><figcaption>Demo</figcaption></figure><h4><strong>Wrapping Up</strong></h4><p>In this article, we enhanced our basic routing system to handle multi-flow scenarios. But there’s more to come! <a href="https://medium.com/@aymen.chouirfi/thinking-outside-the-apple-box-swiftui-navigation-inspired-by-js-routers-part-3-3-ef9e91f85892">In the next installment</a>, we’ll integrate our router into a <strong>modular app architecture</strong> and ensure it meets <strong>Swift 6 Sendability</strong> requirement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d3480fb7017" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>