<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: FraserScottMorrison</title>
    <description>The latest articles on DEV Community by FraserScottMorrison (@fraser-scott-morrison).</description>
    <link>https://dev.to/fraser-scott-morrison</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4026810%2Fbcabde14-0a72-4f58-8837-c679ba367752.png</url>
      <title>DEV Community: FraserScottMorrison</title>
      <link>https://dev.to/fraser-scott-morrison</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fraser-scott-morrison"/>
    <language>en</language>
    <item>
      <title>SPM Modular Programming Architecture</title>
      <dc:creator>FraserScottMorrison</dc:creator>
      <pubDate>Mon, 13 Jul 2026 07:43:00 +0000</pubDate>
      <link>https://dev.to/fraser-scott-morrison/spm-modular-programming-architecture-2a98</link>
      <guid>https://dev.to/fraser-scott-morrison/spm-modular-programming-architecture-2a98</guid>
      <description>&lt;p&gt;Let me frame this article with a couple of not-so-bold predictions for software development.&lt;br&gt;
First, agentic coding will be responsible for the majority of code written. This is already achievable today with an optimised development harness and spec-driven development.&lt;/p&gt;

&lt;p&gt;As a consequence, I expect feature development to accelerate dramatically resulting in codebases that continue to grow in both size and complexity. This is a particular concern for enterprise applications, which are already operating at significant scale.&lt;/p&gt;

&lt;p&gt;To prepare for this new era of code growth, architecture must prioritise &lt;strong&gt;modularity, isolation, and clear dependency boundaries&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This iOS architecture demonstrates a scalable approach that uses &lt;strong&gt;Swift Package Manager (SPM)&lt;/strong&gt; as the foundation for modular application design.&lt;/p&gt;


&lt;h2&gt;
  
  
  Core Concept
&lt;/h2&gt;

&lt;p&gt;At the heart of this architecture is a simple idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Xcode project should be almost empty — everything lives in Swift Packages.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Key principles:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Xcode project is intentionally &lt;strong&gt;extremely thin&lt;/strong&gt;; ideally only 10-15 lines of code&lt;/li&gt;
&lt;li&gt;All features, shared logic, and UI components are implemented as &lt;strong&gt;Swift Packages&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Packages are fully self-contained:

&lt;ul&gt;
&lt;li&gt;Unit tests&lt;/li&gt;
&lt;li&gt;Mocks&lt;/li&gt;
&lt;li&gt;Even UI tests (where applicable)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Dependency management is handled entirely through &lt;code&gt;Package.swift&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Project Structure
&lt;/h2&gt;

&lt;p&gt;App.swift only contains enough code to hand off the the first feature package which handles the entry/launch functionality before routing to the next package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Xcode Project
├── App/
│   └── App.swift
├── Feature Packages/ (local SPM)
│   └── ...
├── Shared Packages/ (local or remote SPM)
│   └── ...
├── Package Dependencies/ (3rd party SPM)
│   └── ...
├── AGENTS.md
└── Harness/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Feature Package Structure
&lt;/h2&gt;

&lt;p&gt;Each feature is fully self-contained. Choose your preferred intra-package architecture such as MVVM-C or uni-directional&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package/
├── Package.swift
├── Sources
│   ├── Concurrent/
│   │   ├── Models/ (Sendable)
│   │   └── Service.swift (actor)
│   │
│   └── Main/ (UI layer)
│       ├── Views/
│       ├── PackageCoordinator.swift
│       └── PackageRoute.swift
│
└── Tests/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Harness
&lt;/h2&gt;

&lt;p&gt;An harness is essential to accurate agentic contributions. The reference project include agentic harness documentation optimised for agents to accurately contribute features. As your project grows the harness must be maintained and optimised to remain effective&lt;/p&gt;




&lt;h2&gt;
  
  
  Concurrency Model
&lt;/h2&gt;

&lt;p&gt;Swift Structured Concurrency can be difficult to adopt correctly, but when used well it provides significant benefits in predictability, stability and UI responsiveness.&lt;br&gt;
Each feature package is split into two logical layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Main&lt;/code&gt; → &lt;code&gt;@MainActor&lt;/code&gt; UI layer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Concurrent&lt;/code&gt; → isolated concurrency layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This provides a clear separation between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI logic&lt;/li&gt;
&lt;li&gt;Asynchronous / concurrent operations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example responsibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Main&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Views&lt;/li&gt;
&lt;li&gt;Coordinators&lt;/li&gt;
&lt;li&gt;Routing logic&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;Concurrent&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Services (&lt;code&gt;actor&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Models (&lt;code&gt;Sendable&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Other actors&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Benefits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Scalability through clear module boundaries
&lt;/li&gt;
&lt;li&gt;Parallel development across agent-assisted teams&lt;/li&gt;
&lt;li&gt;Faster CI by testing only affected packages
&lt;/li&gt;
&lt;li&gt;Single &lt;code&gt;.xcodeproj&lt;/code&gt; (no &lt;code&gt;.xcworkspace&lt;/code&gt;)
&lt;/li&gt;
&lt;li&gt;Agent-friendly, deterministic architecture
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Dependency Management Recommendation
&lt;/h2&gt;

&lt;p&gt;Avoid using:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Xcode → “Add Package Dependencies” UI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It mutates the &lt;code&gt;.xcodeproj&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reduces source control clarity&lt;/li&gt;
&lt;li&gt;Increases the likelihood of merge conflicts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declare dependencies explicitly in each &lt;code&gt;Package.swift&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Pin to exact versions of remote packages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reproducible builds&lt;/li&gt;
&lt;li&gt;Transparent dependency graphs&lt;/li&gt;
&lt;li&gt;CI consistency&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Reference Project
&lt;/h2&gt;

&lt;p&gt;Explore the setup of the thin project, feature packages and the inter-package navigation with this reference project. &lt;/p&gt;

&lt;p&gt;Included is a harness to allow agents to contribute features while adhering to the project's architectral patterns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/fraserscottmorrison/spm-modular-programming" rel="noopener noreferrer"&gt;github.com/fraserscottmorrison/spm-modular-programming&lt;/a&gt;&lt;/p&gt;


    


&lt;p&gt;Google provides an excellent reference Android project for a similarly modular architecture utilising gradle&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/android/nowinandroid" rel="noopener noreferrer"&gt;github.com/android/nowinandroid&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>architecture</category>
      <category>swiftui</category>
    </item>
  </channel>
</rss>
