Skill / SKILL.md

Swift Dependency Injection

wei18/apple-dev-skills

Design injectable seams so Swift services can be swapped for fakes in tests. Use when a type reaches for `URLSession.shared`, `Date()`, `UUID()`, `random(in:)` or a singleton; when asked "how do I inject CloudKit / network / clock" or "should this be a singleton"; when choosing constructor vs `@Environment` / `EnvironmentKey` vs `@TaskLocal` injection; when writing the `makeApp()` composition root; when evaluating swift-dependencies or Factory. Does NOT choose the test framework or snapshot tooling (swift-testing-baseline) or the target layout that hosts the root (swiftpm-modularization).
2 views 18 repository stars 0 commentsUpdated Nov 27, 2026
Overview

Design injectable seams so Swift services can be swapped for fakes in tests. Use when a type reaches for `URLSession.shared`, `Date()`, `UUID()`, `random(in:)` or a singleton; when asked "how do I inject CloudKit / network / clock" or "should this be a singleton"; when choosing constructor vs `@Environment` / `EnvironmentKey` vs `@TaskLocal` injection; when writing the `makeApp()` composition root; when evaluating swift-dependencies or Factory. Does NOT choose the test framework or snapshot tooling (swift-testing-baseline) or the target layout that hosts the root (swiftpm-modularization).

Installation & variants

Download the repository, including the skill’s supporting files.

git clone -- 'https://github.com/wei18/apple-dev-skills' skill-source

Use the complete skill-source/apple-dev-skills/skills/swift-dependency-injection directory with your client’s skill installer.

  • apple-dev-skills/skills/swift-dependency-injection

    main · SKILL.md

    Open installation source

    Source directory recorded from the imported repository path

Source directory apple-dev-skills/skills/swift-dependency-injection

Source instructions
Read source instructions

Open to load source instructions

Original SKILL.md

Open to load the original file

Source & validation
Source status
Awaiting source check
Format validation
Format valid
Checked at
Pending source check
Content SHA-256
b3e4833220514e720d5d616d6fa6a9762a3d33ee8ed8eca7d7fa42ea0b88a205
Discussion
Comments Be the First to Comment

Please log in to comment

    No comments yet

Related skills