ios-dependency-injection | Skill Performance & Reviews | TopRankSkills

TopRank Skills

Home / Skills / development / ios-dependency-injection

ios-dependency-injection

maintained by HoangNguyen0403

star 305 account_tree 90 verified_user MIT License
bolt View GitHub

name: iOS Dependency Injection description: Standards for Protocol-based DI, Property Wrappers, and Factory/Needle. Use when configuring dependency injection or factory patterns in iOS. metadata: labels: [ios, di, dependency-injection, injection, modularity] triggers: files: ['**/*.swift'] keywords: [@Injected, Resolver, Container, Swinject, register, resolve]

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 Factory library for lightweight, type-safe navigation-friendly DI.
  • Swinject: Use for enterprise-grade container-based DI in large modular projects.
  • Injected: Use @Injected property 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

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!

Skill Details

GitHub Stars 305
GitHub Forks 90
Created Mar 2026
Last Updated il y a 5 mois
development development architecture patterns

Related Skills

dagger-design-proposals
chevron_right
nestjs-expert
chevron_right
docker-expert
chevron_right
kafka-streams-topology
chevron_right
kafka-architecture
chevron_right

Build your own?

Join 12,000+ developers contributing to the Claude ecosystem.