swift-dependencies

Manage Swift dependencies with scoped overrides across live, preview, and test contexts.

16|2|Updated Jan 1, 2026
One-click install
npx skills add https://github.com/nonameplum/agent-skills --skill swift-dependencies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-dependencies
Source: https://github.com/nonameplum/agent-skills/tree/main/swift-dependencies
Command: npx skills add https://github.com/nonameplum/agent-skills --skill swift-dependencies

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Swift projects often suffer from brittle dependencies, hard-to-test behavior, and unpredictable runtimes. This skill provides a deterministic mechanism to register, override, and propagate dependencies across tests, previews, and runtime contexts.

Core Features & Use Cases

  • Deterministic dependency values: live, preview, and test values for DependencyKey.
  • Scoped overrides with withDependencies and withEscapedDependencies for safe testing and previews.
  • Easy propagation to child models and components via withDependencies(from:).

Quick Start

  • Install and reference the Dependencies library in your project.
  • Create a DependencyKey conforming type and implement liveValue, testValue, and optional previewValue.
  • Use withDependencies to override dependencies for a single test or feature start, then construct your model.

Frequently Asked Questions about swift-dependencies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I control Swift dependencies for deterministic testing and previews?

You can achieve deterministic Swift dependency control by creating a DependencyKey conforming type with liveValue, testValue, and previewValue, then applying scoped overrides using withDependencies to isolate behavior for tests and SwiftUI previews.

What is the best way to propagate dependency overrides to child models in Swift?

The best way to propagate Swift dependency overrides to child models is using withDependencies(from:) to safely inherit and pass down controlled dependency values from parent contexts to nested components.

Can I scope dependency overrides to a single Swift test without affecting the live runtime?

Yes, you can scope Swift dependency overrides to a single test without affecting the live runtime by using withDependencies or withEscapedDependencies to safely override DependencyValues locally within that test block.

Does this Swift dependency management approach require conforming to specific protocols?

Yes, this Swift dependency management approach requires conforming to the DependencyKey protocol and utilizing DependencyValues to properly register and resolve live, preview, and test dependency contexts.

How do I set up live, preview, and test dependency contexts in a Swift project?

Set up live, preview, and test Swift dependency contexts by implementing a DependencyKey conforming type that defines distinct liveValue, testValue, and optional previewValue properties for deterministic execution across environments.