Apple & iOS
AuraScore 81/100

Modular SPM Architecture and Dependency Decoupling Framework

Design a modular multi-package Swift Package Manager architecture to accelerate build times and decouple feature boundaries.

Use this template when decomposing a monolithic iOS codebase into micro-packages using Swift Package Manager (SPM). It provides a concrete architecture for interface abstraction, dependency injection, and clean build graphs.

Template

Role: Principal iOS Software Architect with deep expertise in Swift Package Manager, compilation graph optimization, and clean architecture.

Context

  • Core Repository: {{target_project}}
  • Target Package Count: {{module_count_target}}
  • Dependency Injection Approach: {{di_approach}}
  • Target Clean Build Time: {{build_time_goal_seconds}}
  • Shared Domain Logic Scope: {{shared_domain_logic}}
  • UI Framework Composition: {{ui_framework_stack}}

Task

Formulate a scalable modularization framework for {{target_project}} that decomposes application logic into isolated Swift Packages, enforcing inverted dependencies via {{di_approach}} to achieve {{build_time_goal_seconds}} build times.

Method

  1. Audit the dependency graph of {{target_project}} to identify high-fan-in utility hubs and cross-feature circular references.
  2. Design a multi-tiered package taxonomy (e.g., Core/Foundations, Domain/Entities, Feature Interfaces, Feature Implementations).
  3. Define interface-only packages containing public protocols and model DTOs to decouple concrete dependencies.
  4. Establish a centralized registration and container strategy using {{di_approach}} for compile-time or runtime resolution.
  5. Structure dynamic versus static library linkage rules in Package.swift to prevent duplicate symbol emission and binary bloat.
  6. Align {{shared_domain_logic}} boundaries to isolate business rules from {{ui_framework_stack}} UI rendering code.
  7. Map out an incremental migration strategy to reach {{module_count_target}} discrete packages while preserving developer velocity.
  8. Formulate CI build matrix settings and local derived data caching to hit {{build_time_goal_seconds}}.

Constraints

  • MUST enforce strict Interface/Implementation package separation to eliminate direct feature-to-feature couplings.
  • MUST NOT introduce circular module dependencies across the Swift Package graph.
  • MUST define explicit accessibility levels (public vs package vs internal) across module boundaries.
  • Code samples must follow modern Swift 5.10+ / 6.0 Package Description syntax.

Output format

  • Section 1: SPM Package Graph Topology (ASCII diagram or table mapping tiers and access boundaries)
  • Section 2: Interface & Registration Blueprint (Swift code illustrating {{di_approach}} with sample interfaces)
  • Section 3: Package.swift Architecture Templates (sample target declarations with explicit target dependencies)
  • Section 4: Incremental Decoupling Roadmap (4-stage migration plan targeting {{module_count_target}} modules)
  • Total length: 450-800 words.

Self-review

  • Ensure all 6 context variables are deeply woven into the structural rules.
  • Verify that package dependency directions flow strictly inward toward core domains.
  • Confirm that build performance tactics directly support the {{build_time_goal_seconds}} threshold.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-apple
software-engineering-debugging
ios
spm
architecture