How do you approach designing a scalable and maintainable architecture for an iOS app?
Instruction: Describe architectural patterns and principles you apply to ensure an app's codebase is scalable and maintainable.
Updated
Official answer
Start with the app's actual workflows, deployment targets, offline needs, data sensitivity, team size and expected change patterns. Distinguish codebase growth from runtime throughput; an architectural label does not solve both automatically.
Use a small separation between presentation, state/use cases and data access. UIKit MVC can work with disciplined controllers; SwiftUI often benefits from explicit observable state and injected dependencies. Choose MVVM or another pattern because it clarifies responsibilities, not because every project needs all of its layers. A view model should not become a second oversized controller.
Give each piece of mutable state an owner, lifecycle and concurrency boundary. Define how loading, empty, error, cancellation and stale-response states are represented. Keep UI updates on the appropriate actor, and encapsulate persistence and networking behind interfaces where substitution or policy separation is useful. Avoid an interface for every trivial type without a concrete benefit.
Create modules around stable capabilities and minimize dependency cycles. A module can be tested in isolation, but changing its public contract can still affect callers, migrations and performance. Add integration tests for those boundaries and keep versioned storage/network compatibility in view, especially while older app releases remain active.
Use dependency injection for clocks, services and storage when it makes deterministic tests possible. Document key decisions and ownership, apply consistent conventions, and measure build time, regression rate and change effort. Profile meaningful user tasks and maintain resource budgets rather than assuming a modular architecture is inherently fast.
Evolve the design from evidence. For example, extract an account-specific cache boundary when cross-account invalidation becomes difficult, with tests for sign-out and concurrent requests. Scalability and maintainability remain outcomes to verify, not guarantees supplied by a pattern.
Swift concurrency, Observable model ownership, Module and dependency tradeoffs