Skip to content
CAI
Software that uses CAICheck a score

pointfreeco/swift-dependencies

52.5

Adequate · 1 October 2026

6k

lines of production code

Swift

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Swift library for dependency injection that provides a type-safe, testable framework for managing application dependencies. It enables developers to decouple code by allowing runtime overrides of dependencies for testing, previews, and different environments, while ensuring strict concurrency safety through Swift 6 support. The library features macro-based code generation to simplify client creation and integrates deeply with the Swift Testing framework for isolated test execution.

Features

Add Swift Testing integration for dependency overrides

Introduces support for the Swift Testing framework by adding a \TestScoping\ and \SuiteTrait\ implementation that allows tests to quarantine and override dependencies. Users can now apply \.dependencies\ or \.dependency\ traits directly to \@Suite\ or \@Test\ declarations to isolate dependency state, and can cast overridden dependencies to concrete types using the new \@Dependency(..., as: Type.self)\ initializer.

Sources/DependenciesTestSupport · high confidence

Integration app demonstrates dependency context overrides via environment variables

The Integration sample app now supports overriding dependency values through the SWIFT\_DEPENDENCIES\_CONTEXT environment variable, allowing users to switch between 'live', 'preview', and 'test' contexts at runtime. This is demonstrated by the IntegrationUITests, which verify that setting this environment variable correctly changes the displayed text in the app, and by SwiftUI previews that show how dependencies can be overridden for preview purposes.

Integration · high confidence

Introduce @DependencyEntry macro with \_modify accessor

The \DependenciesMacrosPlugin\ now includes the \@DependencyEntry\ macro, which generates accessors for dependency values. A key behavioral addition is the inclusion of a \\_modify\ accessor in the generated code, enabling mutable access to dependency entries. This macro works alongside the existing \@DependencyClient\ and \@DependencyEndpoint\ macros to provide a more complete macro-based dependency injection system.

Sources/DependenciesMacrosPlugin · high confidence

Introduce preview and test traits for overriding dependencies

This change introduces new \.dependency\ and \.dependencies\ traits for SwiftUI previews, allowing developers to override dependency values directly in the \\#Preview\ macro without nesting calls to \withDependencies\. If a dependency override throws an error, the preview renders a red overlay displaying the error message instead of crashing. Additionally, a \TestTrait\ is added to manage test-specific dependency values, with implementation details adjusted for Swift versions prior to 6.1.

Sources/Dependencies/Traits · high confidence

Introduces @DependencyClient and @DependencyEndpoint macros for dependency clients

This change adds the \@DependencyClient\ and \@DependencyEndpoint\ macros to the \DependenciesMacros\ module. The \@DependencyClient\ macro automatically generates a public initializer for dependency client structs and provides default, unimplemented values for closure endpoints, which trigger test failures if invoked without being overridden. The \@DependencyEndpoint\ macro generates methods with named argument labels for closure properties and allows custom method naming, while \@DependencyEndpointIgnored\ marks properties to be excluded from this automatic generation.

Sources/DependenciesMacros · high confidence

Swift 6.0 and 6.3 support with modular dependency traits

The library now supports Swift 6.0 and 6.3, introducing package traits to make dependencies like Clocks, CombineSchedulers, Foundation, and FoundationNetworking optional. This allows users to reduce binary size and build times by excluding unused features, while the package also enables several upcoming Swift concurrency features for stricter type safety. Additionally, the build system has been updated to support static linking via \--static-swift-stdlib\ and includes configuration for Swift Testing integration.

(repo-wide) · high confidence

Behavioural changes

Dependency access now uses Sendable key paths and supports type-based initialization

The \@Dependency\ property wrapper now requires \Sendable\ key paths and supports initializing with a dependency key type (e.g., \@Dependency(Settings.self)\) in addition to the existing key path syntax. This change improves type safety and aligns with Swift 6 concurrency requirements. Additionally, the library introduces \prepareDependencies\ for setting up initial dependencies at the application entry point, and updates the test failure reporting to provide more detailed context about unimplemented dependencies.

Sources/Dependencies · high confidence

Integration project added to workspace

The Xcode workspace has been updated to include the Integration project (Integration.xcodeproj), making it available for development and build configurations within the workspace.

Dependencies.xcworkspace · high confidence

Internal macro module now exports IssueReporting

The internal implementation of the DependenciesMacros module now re-exports the IssueReporting library. This change ensures that any code generated by the macros (such as @DependencyClient) has immediate access to IssueReporting's types and symbols without requiring explicit imports in the generated code, simplifying the macro output and reducing boilerplate for users relying on these generated dependencies.

Sources/DependenciesMacros/Internal · high confidence

Migration to ConcurrencyExtras and removal of internal concurrency helpers

The library removes its internal concurrency support files (ActorIsolated, LockIsolated, UncheckedSendable, AsyncStream helpers, etc.) and now depends on the ConcurrencyExtras package for these utilities. Deprecated APIs like \streamWithContinuation\ are now aliases to ConcurrencyExtras' \makeStream\ functions, and internal exports have been updated to include ConcurrencyExtras and IssueReporting while conditionally exporting Clocks and CombineSchedulers.

Sources/Dependencies/Internal · high confidence

New assert and precondition dependencies, plus NotificationCenter support

This update introduces new controllable dependencies for assertions and notifications, allowing features to use \@Dependency(\\.assert)\ and \@Dependency(\\.precondition)\ as testable substitutes for Swift's standard functions, and adds \@Dependency(\\.notificationCenter)\ for decoupled notification handling. Additionally, the \fireAndForget\ dependency now supports naming tasks via a new \name\ parameter, and several existing dependencies (such as \date\, \locale\, \timeZone\, and \urlSession\) have been updated to use \reportIssue\ instead of \XCTFail\ for test failures, improving compatibility with Swift Testing.

Sources/Dependencies/DependencyValues · high confidence

Test coverage

Added XCTTODO test helper for known failures; Added macro expansion and runtime tests for DependenciesMacros; Expanded test coverage for dependency injection behaviors and new dependencies.

Dependencies

Swift Dependencies 1.0: Macro support, platform upgrades, and dependency overhaul

This release upgrades the minimum supported platforms to iOS 15, macOS 12, tvOS 15, and watchOS 9, and raises the Swift tools version to 6.4. It introduces a new \@DependencyClient\ macro system via the \DependenciesMacros\ product and \DependenciesMacrosPlugin\ target, enabling compile-time client generation. The dependency graph has been significantly restructured: \swift-argument-parser\ and \swift-benchmark\ are removed, while \swift-concurrency-extras\, \swift-issue-reporting\, and \swift-syntax\ (509–605) are added. The package now uses platform-specific traits (e.g., \Clocks\, \CombineSchedulers\) to conditionally include dependencies, and enables several upcoming Swift language features for stricter concurrency and import safety.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 58 → 52 (-5.3)
  • Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 91 → 93 (+2.2)
  • Architecture 98 → 98 (-0.3)
  • Maturity 55 → 55 (-0.2)
  • Readiness 53 → 42 (-10.6)
  • Security 50 → 50 (+0.0)

Resolved (2)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)

New (21)

  • Coverage not measured — Swift suite
  • DependencyEntryMacro.swift.keyTypeName (cyclomatic 16) (Sources/DependenciesMacrosPlugin/DependencyEntryMacro.swift)
  • Duplicated block (10 lines × 2) (Sources/DependenciesMacrosPlugin/DependencyEndpointMacro.swift)
  • Duplicated block (14 lines × 2) (Sources/DependenciesMacrosPlugin/DependencyEntryMacro.swift)
  • Duplicated block (16 lines × 2) (Sources/Dependencies/WithDependencies.swift)
  • Duplicated block (29 lines × 2) (Sources/Dependencies/WithDependencies.swift)
  • Duplicated block (33 lines × 2) (Sources/Dependencies/WithDependencies.swift)
  • Off the main sequence: Dependencies
  • Off-boarding risk: anonymized user #1
  • Outdated: combine-schedulers
  • Outdated: swift-clocks
  • Outdated: swift-concurrency-extras
  • Outdated: swift-custom-dump
  • Outdated: swift-issue-reporting
  • Outdated: swift-macro-testing
  • Outdated: swift-snapshot-testing
  • Outdated: xctest-dynamic-overlay
  • Redundant overloads for multi-key updates. Similar to withValue, there are two overloads of withValues differing only by the async nature of the operation closure. This duplication applies to the multi-key update pattern as well.
  • Redundant overloads for single-key updates. The library provides two overloads of withValue that differ only by the async nature of the operation closure. While technically distinct signatures, they represent the same logical operation (scoping a single dependency value) and increase cognitive load compared to a single withValue that accepts an async-compatible closure or relies on the caller to wrap the sync case.
  • Redundant overloads for test-specific scoped updates. Two overloads of withTestValues differ only by the async nature of the operation closure.
  • …and 1 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

pointfreeco/swift-dependencies was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit b476cc5761057d8d857de063fe7ac8daecf5c06b — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.