> ios-dependency-injection
Standards for Protocol-based DI, Property Wrappers, and Factory/Needle. Use when configuring dependency injection or factory patterns in iOS. (triggers: **/*.swift, @Injected, Resolver, Container, Swinject, register, resolve)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/ios-dependency-injection?format=md"iOS Dependency Injection Standards
Priority: P0
Implementation Guidelines
Protocol-Based DI (Manual)
- Initializer Injection: Preferred method. Pass dependencies through
init. - Abstractions: Inject protocols instead of concrete classes to facilitate testing (Mocks/Stubs).
Modern Property Wrappers (Factory/Resolver)
- Factory: Use the
Factorylibrary for lightweight, type-safe navigation-friendly DI. - Swinject: Use for enterprise-grade container-based DI in large modular projects.
- Injected: Use
@Injectedproperty wrappers for cleaner syntax in ViewModels.
Scoping
- Singleton: Use for app-wide services (Auth, Network, Database).
- Unique/Transient: Default for ViewModels and temporary workers.
- Graph/Cached: Use for shared data within a specific feature flow (Coordinator scope).
Anti-Patterns
- Singletitis:
**No global Shared singleton access everywhere**: Inject the service via initializer. - Service Locator:
**No Resolver.resolve() inside logic**: Pass dependency via constructor or property wrapper. - Concrete Dependency:
**No direct class instantiation**: Depend on protocols for testability.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)