Agent Skills: iOS Dependency Injection

Configure protocol-based DI with property wrappers and Factory/Swinject. Use when setting up dependency injection or factory patterns in iOS. (triggers: **/*.swift, @Injected, Resolver, Container, Swinject, register, resolve)

UncategorizedID: hoangnguyen0403/agent-skills-standard/ios-dependency-injection

Install this agent skill to your local

pnpm dlx add-skill https://github.com/HoangNguyen0403/agent-skills-standard/tree/HEAD/skills/ios/ios-dependency-injection

Skill Files

Browse the full folder contents for ios-dependency-injection.

Download Skill

Loading file tree…

skills/ios/ios-dependency-injection/SKILL.md

Skill Metadata

Name
ios-dependency-injection
Description
Configure protocol-based DI with property wrappers and Factory/Swinject. Use when setting up dependency injection or factory patterns in iOS.

iOS Dependency Injection

Priority: P0

Implementation Workflow

  1. Prefer initializer injection — Pass dependencies through init as primary approach.
  2. Inject protocols — Always depend on protocols instead of concrete classes for testability.
  3. Choose DI library — Use Factory for lightweight DI, Swinject for enterprise-grade container-based projects.
  4. Apply correct scoping — Singleton for app-wide services (Auth, Network); Unique/Transient for ViewModels; Graph/Cached for feature flows.

See protocol-based DI and Factory registration examples

Anti-Patterns

  • No Global Singletons: Inject services via initializer
  • No Inline Service Resolution: Pass dependencies via constructor; avoid Resolver.resolve() in business logic
  • No Concrete Class Dependencies: Depend on protocols for testability

References