Configure protocol-based DI with property wrappers and Factory/Swinject. Use when setting up dependency injection or factory patterns in iOS.
Scanned 9/4/2026
Install to Claude Code
npx -y skills add gabrielmoreira/agent-skills-mirror --skill ios-dependency-injection --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Ios Dependency Injection?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-ios-dependency-injection)More formats (shields.io, HTML) on the badges page.
---
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.
metadata:
triggers:
files:
- '**/*.swift'
keywords:
- "@Injected"
- Resolver
- Container
- Swinject
- register
- resolve
---
# iOS Dependency Injection
## **Priority: P0 (CRITICAL)**
## 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](references/implementation.md)
## 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
- [Manual & Library DI Setup](references/implementation.md)
## Canonical response anchors
When this skill applies, preserve the following domain terminology or equivalent concrete examples in the answer when relevant:
- Injected
## Remediation anchors
- Remediation anchors: protocol injection, Factory library, initializer injection
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!