home / skills / shotaiuchi / dotclaude / ios-architecture

ios-architecture skill

/dotclaude/skills/ios-architecture

This skill helps iOS developers implement MVVM architecture in SwiftUI using async/await and Combine, improving code organization and testability.

npx playbooks add skill shotaiuchi/dotclaude --skill ios-architecture

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.4 KB
---
name: iOS Architecture
description: This skill should be used when implementing iOS features, creating SwiftUI views, setting up ViewModels, using async/await or Combine, or following MVVM patterns on iOS.
references:
  - path: ../../references/common/clean-architecture.md
  - path: ../../references/common/testing-strategy.md
  - path: ../../references/platforms/ios/conventions.md
  - path: ../../references/platforms/ios/architecture-patterns.md
external:
  - id: swift-concurrency
    # Resolved via: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/
  - id: swiftui-docs
    # Resolved via: https://developer.apple.com/documentation/swiftui/
  - id: combine-docs
    # Resolved via: https://developer.apple.com/documentation/combine/
  # Note: External references are resolved by the skill loader. See references/README.md for configuration.
---

**Always respond in Japanese.**

# iOS Architecture

SwiftUI + MVVM / State management patterns based on Apple's official guidelines.

Read and apply the patterns from the referenced documents to the user's implementation task.

## Reference Documents

- [Clean Architecture Guide](../../references/common/clean-architecture.md)
- [Testing Strategy Guide](../../references/common/testing-strategy.md)
- [iOS Conventions](../../references/platforms/ios/conventions.md)
- [Architecture Patterns](../../references/platforms/ios/architecture-patterns.md)

Overview

This skill provides practical guidance for implementing iOS features using SwiftUI and MVVM with modern state management. It consolidates Apple-recommended patterns for ViewModels, async/await and Combine integration, and clean separation of concerns. Use it to align implementations with testing and iOS conventions while keeping code maintainable and testable.

How this skill works

The skill inspects UI requirements and maps them to SwiftUI views, observable ViewModels, and domain/service layers following clean architecture principles. It recommends how to wire state flows using @StateObject, @Published, async/await tasks, or Combine publishers depending on needs. It also suggests testable boundaries, dependency injection points, and strategies for side-effect handling and error propagation.

When to use it

  • Building new SwiftUI screens that need a clear MVVM separation
  • Converting UIKit features to SwiftUI while preserving business logic
  • Choosing between async/await and Combine for network or database tasks
  • Designing ViewModels that must be unit-tested independently from views
  • Creating scalable modules that follow clean architecture layers

Best practices

  • Keep Views declarative and free of business logic; delegate to ViewModels
  • Use @StateObject in views that own ViewModel lifecycle; use @ObservedObject for injected VM
  • Model side effects as async functions or Combine publishers in the domain layer
  • Return plain value types for UI state when possible to simplify tests
  • Inject services and repositories via protocols to enable mocking in tests
  • Prefer structured concurrency (async/await) for linear async flows; use Combine for continuous streams

Example use cases

  • Create a list-detail SwiftUI flow with a List view, Detail view, and shared ViewModel using Combine for live updates
  • Implement login flow where ViewModel validates input, calls async network API, and maps errors to UI-friendly messages
  • Refactor a legacy MVC screen into MVVM: extract business logic into Use Cases and expose UI state via Published properties
  • Design offline-first data sync: repository exposes async methods, ViewModel coordinates sync tasks and updates UI state

FAQ

When should I prefer async/await over Combine?

Prefer async/await for single-shot, linear async tasks like HTTP requests or database fetches. Use Combine for event streams, continuous updates, or when composing multiple publishers.

How do I test ViewModels effectively?

Design ViewModels to depend on protocol-based services. Inject test doubles and assert Published outputs or state values after driving async calls with deterministic schedulers or Task testing helpers.