Set Up Dependency Injection
2 fill-in slots · from The AI Prompt Handbook for Mobile App Development
Your details
0/2 filledSet Up Dependency Injection
Background: Native [iOS SwiftUI+Combine / Android Jetpack Compose / both] app using [architecture]. Right now dependencies are [created inline / singletons everywhere / passed by hand]. Key dependencies: [e.g., API client, database, auth service, analytics]. Use case: Design a dependency injection approach so I can swap real implementations for mocks in tests and avoid a tangle of singletons. Implementation details: - iOS: compare manual constructor injection, an @Environment-based approach for SwiftUI, and a container library. Avoid heavyweight setup for a small app. - Android: compare manual/constructor injection vs Hilt/Koin; show how scoping works (app vs screen scope). - Dependencies should be defined behind protocols/interfaces, not concrete types - Show how a view model receives its dependencies Layer & dependencies: Composition should happen at the app's entry/ assembly point; lower layers receive dependencies, never reach for them. Deliverable: A recommended DI approach with reasoning, the wiring code for one real dependency end to end (definition → injection → use in a view model), and how the same dependency is replaced with a mock in a unit test.
Highlighted [slots] are still empty. Downloads are plain .txt — paste into any AI assistant.