# hmlongco/Factory

A modern approach to Container-Based Dependency Injection for Swift and SwiftUI.

Repository: https://github.com/hmlongco/Factory
Canonical: https://ross.abutalabs.com/products/factory
Language: Swift
License: MIT
License Family: permissive
Topics: container, dependency-injection, ios, swift, swiftui, xcode
Last push: 2026-08-11T00:28:59+00:00

## Health v2 (maintenance only)
Score: 96/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 97, release rhythm 93, longevity 100
- inputs: {"age_days": 1554, "days_push": 23, "days_rel": 49, "gap_med": 3.0, "n_releases_24m": 29}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2895, forks 192 (observed 2026-08-28T04:07:28.677355+00:00)

## What it is
Factory is a lightweight, compile-time safe dependency injection library for Swift and SwiftUI, built around container-based factory registrations. It supports scopes, parameters, contexts, and easy testing with minimal setup and no code generation.

## Use cases
- dependency injection in swiftui apps
- replace storyboard singletons with injectable services
- unit test view models with mocked dependencies
- swiftui preview with mock services
- manage service lifetimes with scopes
- ios mvvm architecture with injected dependencies

## When to choose
- you want a lightweight DI solution with no build scripts or code generation
- your project uses SwiftUI or UIKit on Apple platforms
- you need compile-time safety for service resolution
- you want fast resolution and easy testability

## When to avoid
- you need dependency injection on non-Apple platforms
- you prefer purely constructor-based injection without a container
- your team standardizes on a different DI framework already

## Facets
- artifact type: library
- maturity: active
- function: middleware, developer-tools, testing
- domain: mobile-development, developer-tools, cross-platform
- platform: -
- tags: dependency-injection, swiftui, service-locator, containers, mvvm, swift, ios, macos

## Member repositories
- hmlongco/Factory (main) score 96

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:28.677355+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:35:16.338435+00:00, confidence not recorded.
  - readme: https://github.com/hmlongco/Factory (fetched 2026-08-28T04:07:28.677355+00:00, sha 94778d3f647d)
- Data as of 2026-08-30T08:39:29.467469+00:00.
