ios-di

Organizes dependency injection for SwiftUI apps using protocol-oriented design.

1|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill ios-di
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ios-di
Source: https://github.com/dimitriRemoiville/cc-mobile/tree/main/plugins/cc-mobile-ios/skills/ios-di
Command: npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill ios-di

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dependency injection helps structure and decouple components in iOS apps, enabling easier testing and maintainability.

Core Features & Use Cases

  • Protocol-oriented DI: define dependencies as protocols and provide concrete implementations at the composition root.
  • Testability: facilitate easy swapping with mocks or stubs in unit tests.
  • App architecture guidance: demonstrates no singletons, constructor injection, and explicit dependencies across view models, use cases, and repositories.

Quick Start

Set up a DIContainer at app startup and inject dependencies into a sample view model.

Frequently Asked Questions about ios-di

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up dependency injection in SwiftUI for better testing?

To use dependency injection in SwiftUI, define dependencies as protocols and inject concrete implementations via a DIContainer at app startup, enforcing constructor injection and no singletons for testable view models.

What is protocol-oriented dependency injection in iOS apps?

Protocol-oriented dependency injection in iOS apps is an architecture pattern where dependencies are defined as protocols. This allows easy swapping with test doubles like mocks or stubs during unit testing while maintaining explicit dependencies across repositories and view models.

How do I configure a DIContainer for SwiftUI view models?

Configure a DIContainer for SwiftUI view models at app startup by registering explicit dependencies. The container supports both live variations for production and preview variations, injecting required repositories and use cases directly into view models.

Does explicit dependency injection work without singletons in SwiftUI?

Yes, explicit dependency injection works without singletons in SwiftUI by enforcing constructor injection and protocol-based dependencies. This approach decouples components by requiring explicit dependencies passed directly through constructors rather than global access.

Can I use mocks and stubs for unit testing SwiftUI view models with explicit dependencies?

Yes, you can use mocks and stubs for unit testing SwiftUI view models when using explicit dependencies. Protocol-oriented design allows easy swapping with test doubles, ensuring components are fully decoupled and isolated during tests.