hmlongco/Factory
66.1
Adequate · 30 September 2026
4.4k
lines of production code
Swift
primary language
2
measurements over time
What this system is
FactoryKit is a dependency injection library for Swift that provides container-based service resolution with support for both service locator and explicit injection patterns. It features concurrency-safe operations using atomics and task-local storage, enabling safe parallel test execution and integration with modern Swift concurrency models like Actors and the Observation framework. The system includes a dedicated testing module for isolating container state and context-aware registration for different environments such as previews and tests.
How it got here
2022 — FactoryKit 3.4.1 release and demo expansion
7 changes.
This period focused on releasing FactoryKit 3.4.1 with Swift 6 concurrency support and performance optimizations, while establishing the initial repository structure and documentation. The FactoryDemo application was significantly expanded to showcase advanced features, including the Observation framework, multi-module architectures, and modern concurrency patterns.
2023 — Modularization and DI infrastructure
5 changes.
The project restructured the FactoryDemo app by extracting Common and Networking modules into standalone Xcode projects with their own build targets. These modules were integrated with the FactoryKit dependency injection framework, defining protocols and service registrations. Parallel-safe testing infrastructure and initial test scaffolding were added to support the new modular architecture.
2025–2026 — FactoryKit 3.0 concurrency overhaul
7 changes.
This period focused on releasing FactoryKit 3.0, which introduced a redesigned container architecture using @TaskLocal for concurrency-safe dependency injection and replaced legacy locking with atomics to fix data races. The work included adding comprehensive test suites for Swift Testing and XCTest to validate isolation, parallel execution, and thread safety, alongside new documentation and demo scripts.
Features
Add ContainerTrait for isolated dependency injection in Swift Testing
Introduces the \ContainerTrait\ struct in the \FactoryTesting\ module, enabling developers to isolate the shared dependency container for individual Swift Testing test cases. This allows tests to run in parallel without interference by providing a scoped container via \TestTrait\ and \SuiteTrait\ conformance, automatically cloning the singleton scope and allowing optional pre-test transformations.
Sources/FactoryTesting · high confidence
Added FactorySimpleDemo app and tests
A new demo application, FactorySimpleDemo, has been added to showcase the FactoryKit dependency injection library. The app features a SwiftUI interface that displays a name loaded via a registered service and includes a button to reload the view. It demonstrates both formal and sugared service registration syntax within SwiftUI previews. Additionally, a corresponding test suite using the FactoryTesting framework has been included to verify service resolution and mocking capabilities.
FactorySimpleDemo · high confidence
Added scripts to copy FactoryKit files and generate documentation
A new Swift script (Scripts/copy.swift) was added to copy .swift files from the FactoryKit source directory to the Factory directory, and a shell script (Scripts/docs.sh) was introduced to generate static documentation for the FactoryKit target using Swift Package Manager.
Scripts · high confidence
Demo app adds concept examples for concurrency, async initialization, and dependency patterns
The FactoryDemo application now includes a new Concepts section demonstrating how to use FactoryKit with modern Swift features. This includes examples of injecting and using Actors and MainActor-isolated types, handling asynchronous initializers via a caching wrapper, and resolving circular dependencies. It also provides demonstrations of generic type injection, tagged factories with priority-based resolution, and best practices for defining non-extendable service containers.
FactoryDemo/FactoryDemo/Concepts · high confidence
Demo app adds container-specific and observation-based dependency injection examples
The FactoryDemo app now includes new SwiftUI views and view models that demonstrate advanced FactoryKit features. ContainerDemoView and ContainerDemoViewModel show how to use custom shared containers (MyCustomContainer) and inject them via @Injected. ObservableView demonstrates integrating the new Observation framework with FactoryKit on iOS 17+, allowing injected @Observable services to be mutated and trigger UI updates. Additionally, ModelTest shows how to use environment-specific registrations (onPreview, onTest) to provide different data for previews and tests, while the UI tests verify that launch arguments can trigger specific mock registrations.
FactoryDemo/FactoryDemo · high confidence
Initial repository structure and documentation for FactoryKit 3.4.1
This change establishes the initial repository layout for the FactoryKit dependency injection library, including the core source modules (FactoryKit and FactoryTesting), comprehensive DocC documentation, and a demo application. It introduces the \.spi.yml\ configuration for Swift Package Index documentation generation, a \CLAUDE.md\ guide for AI-assisted development, and a \Factory.xctestplan\ for test execution. The entry also includes the full changelog for version 3.4.1, which highlights scope performance optimizations, lock reclamation, and fixes for concurrent resolution and cache key collisions, alongside updated README and code of conduct files.
(repo-wide) · high confidence
Initialize FactoryDemo workspace configuration
The FactoryDemo workspace has been initialized with standard Xcode configuration files, including the workspace data file, workspace settings, and IDE checks. This establishes the basic project structure required to open and build the demo application in Xcode.
FactoryDemo/FactoryDemo.xcodeproj/project.xcworkspace · high confidence
Introduce Common module with FactoryKit dependency injection definitions
The FactoryDemo app now includes a new Common module that provides a shared framework for dependency injection using FactoryKit. This module defines a CommonType protocol and registers specific implementations within the DI container, including a standard Common implementation, a singleton fatalType factory, and a promisedType factory that returns nil. It also contains a MacroCommonType implementation, though its registration via macro is currently commented out.
FactoryDemo/Modules/Common/Common · high confidence
Networking module introduces dependency injection and test infrastructure
The Networking module now includes a public header for framework versioning and a Swift implementation that defines a NetworkType protocol. It registers network service instances within the FactoryKit dependency injection container and introduces a FatalCommonType class, establishing the module's internal structure and test capabilities.
FactoryDemo/Modules/Networking/Networking · high confidence
Behavioural changes
FactoryDemo modules restructured into standalone Xcode projects
The Common and Networking modules in the FactoryDemo app have been reorganized from their previous structure into distinct Xcode projects (Common.xcodeproj and Networking.xcodeproj). Each module is now built as a standalone framework (Common.framework and Networking.framework) with its own unit test bundle. The Networking module explicitly depends on and embeds the Common framework, while both modules integrate with the FactoryKitDynamic dependency. This change affects how the demo app's internal module boundaries are defined and built within Xcode.
FactoryDemo/Modules/Common/Common.xcodeproj, FactoryDemo/Modules/Networking/Networking.xcodeproj · high confidence
FactoryDemo project restructured for multi-module and concurrency support
The FactoryDemo Xcode project has been updated to demonstrate modern Swift concurrency patterns and multi-module architectures. The demo app now includes examples for Observable views, UI testing, and automatic registration, while also integrating external modules like Common and Networking. Additionally, the project configuration has been adjusted to support Swift 6 conformance and Xcode 16, ensuring compatibility with the latest language and toolchain features.
FactoryDemo/FactoryDemo.xcodeproj · medium confidence
FactoryKit 3.0: New container architecture and concurrency-safe injection
FactoryKit has been updated to version 3.0, introducing a redesigned container system with \SharedContainer\ and \ManagedContainer\ protocols to better support both service locator and explicit dependency injection patterns. The library now uses \@TaskLocal\ for the shared container to enable safer isolation in concurrent environments, particularly for test parallelization. Concurrency safety has been significantly improved by replacing legacy locking mechanisms with atomics and \os\_unfair\_lock\ (or \pthread\_mutex\ on non-Apple platforms), fixing data races in \@LazyInjected\ and \@WeakLazyInjected\ wrappers during concurrent first access. Additionally, the \dependency()\ function is now the preferred way to resolve dependencies via keypaths, deprecating the older \resolve()\ function, and new context-aware registration features allow factories to behave differently in previews, tests, or debug modes.
Sources/FactoryKit/FactoryKit · high confidence
Test coverage
Added Swift Testing suite for isolation, nonisolated, and parallel container behaviors; Added comprehensive test suite for FactoryKit; Added concurrency and isolation test fixtures; Added initial test scaffolding for Common and Networking modules; Added parallel-safe testing infrastructure and mock registration tests; Configured Xcode scheme to run unit and UI tests with code coverage.
Dependencies
FactoryKit 3.0 release with Swift 6 concurrency and expanded platform support
The Factory dependency injection framework has been updated to version 3.0, introducing full Swift 6 conformance with strict concurrency checking enabled. This release raises the minimum deployment targets to iOS 15, tvOS 15, watchOS 9, macOS 12, and visionOS 1, while adding a new dynamic library product (FactoryKitDynamic) and a dedicated testing target (FactoryTesting). The package now includes a privacy manifest resource and depends on the Swift DocC plugin for documentation generation.
(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 73 → 66 (-7.1)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 98 → 98 (-0.0)
- Architecture 96 → 95 (-0.2)
- Maturity 63 → 63 (-0.0)
- Readiness 65 → 51 (-14.2)
- Security 97 → 97 (+0.0)
Resolved (4)
- Documentation: no contributor guidance (README.md)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Repeated repair: Sources/FactoryKit/FactoryKit/Injections.swift (Sources/FactoryKit/FactoryKit/Injections.swift)
New (8)
- Ambiguous overload resolution: ManagedContainer uses callAsFunction for both creating Factory and ParameterFactory instances. While Swift supports overloading, this can be confusing for users who expect callAsFunction to be the primary resolution mechanism (like in Factory/ParameterFactory), but here it is a registration/creation mechanism. It conflicts with the semantic expectation of callAsFunction as 'invocation/resolution' seen in other types.
- Inconsistent reset API: Injected, LazyInjected, and WeakLazyInjected expose a resolve(reset:) method to trigger a reset during resolution, whereas InjectedContainer exposes a separate reset(options:) method. This creates two different patterns for the same intent (resetting a container/dependency state) across similar types.
- Low coverage: Sources/FactoryKit/FactoryKit/Dependency.swift (Sources/FactoryKit/FactoryKit/Dependency.swift)
- No assertions: testCachedConcurrentFirstResolution (Tests/FactoryTests/XCTests/FactoryConcurrencyStressTests.swift)
- No assertions: testSingletonConcurrentFirstResolution (Tests/FactoryTests/XCTests/FactoryConcurrencyStressTests.swift)
- Off the main sequence: FactoryKit
- Redundant resolution methods: callAsFunction and resolve perform the exact same operation (resolving a dependency) on Factory.
- Redundant resolution methods: callAsFunction and resolve perform the exact same operation (resolving a parameterized dependency) on ParameterFactory.
Changes since last survey
- 12 commits — 8 feature/other, 4 fixes
By area
- (root) — 6 commits
- (repo) — 4 commits
- Sources/FactoryKit — 1 commit
- Tests/FactoryTests — 1 commit
Notable commits
- fix: Fix concurrent first resolution of cached dependencies
- fix: Fix parameter-scoped cache key hash collisions
- fix: Merge pull request #384 from lucaspham1/fix/parameter-hash-collisions
- fix: Merge pull request #385 from lucaspham1/fix/concurrent-cached-resolution
- change: Changelog for 384
- change: Changelog for 384
- change: Changelog for 385
- change: Merge pull request #380 from revolter/patch-1
- change: Merge pull request #381 from hxperl/docs/registration-parameter-docs
- change: Reclaim scope resolution locks #387
- change: Scope performance optimization #389
- change: Update for xcode 27
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
hmlongco/Factory 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 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 39d340fbfc4eb79a8981e9166083cda011a6b3f8 — 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-cb25ca4feafa.