ios-architecture-expert

Guides building modular, testable iOS/Swift applications following the Essential Developer methodology -- clean architecture with protocol-oriented design, composition root, generic presenters, and modern Swift concurrency. Use when designing features, structuring modules, composing dependencies, or reviewing iOS architecture.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "ios-architecture-expert" with this command: npx skills add swiftyjourney/ios-architecture-expert-skill/swiftyjourney-ios-architecture-expert-skill-ios-architecture-expert

iOS Architecture Expert — Essential Developer Methodology

Agent Behavior Contract

When this skill is active, follow these rules strictly:

  1. Feature modules have zero UIKit/SwiftUI imports — only Foundation. Domain models, use cases, presenters, and API/cache logic never depend on a UI framework.
  2. Define protocol boundaries at every layer transitionFeedStore, HTTPClient, ResourceView, FeedCache, etc. Concrete types live behind protocols.
  3. Domain models are value typesstruct, Hashable, Sendable. No classes for models.
  4. Presentation logic is framework-agnostic — presenters output view models (structs). No UIImage, UIColor, or SwiftUI types in the presentation layer.
  5. All dependency wiring happens in the Composition Root — the app target (or a dedicated CompositionRoot module). Feature modules never create their own dependencies.
  6. Tests drive the design — one test class per use case, named by behavior (CacheFeedUseCaseTests, not LocalFeedLoaderTests). Use makeSUT() factory in every test class.
  7. Use SPM multi-target packages for module separation — EssentialFeed (Foundation), EssentialFeediOS (UIKit), EssentialApp (composition).
  8. Prefer async/await over closures/Combine for async operations. Use Task.immediate for synchronous-first execution in adapters.
  9. Use Swift Testing (@Test, #expect) for new tests. Follow patterns in the swift-testing-expert skill when available.
  10. Mark shared mutable state with @MainActor — presenters, adapters, view controllers, and composition code run on the main actor.

Architecture Layers

LayerResponsibility
FeatureDomain models (struct, Sendable) and abstract use-case protocols. Zero framework imports beyond Foundation.
APIEndpoint enums, static mappers with private Decodable types, HTTPClient protocol.
CacheStore protocols, local models (decoupled from domain), use-case orchestrators, cache policy objects.
PresentationGeneric LoadResourcePresenter<Resource, View>, view model structs, localized error strings.
UI (UIKit)View controllers, cells, DiffableDataSource, CellController type-erasure. Conforms to presenter view protocols.
UI (SwiftUI)@Observable view models, View composition, environment-based DI. Same presenter patterns, different binding.
CompositionComposer static factories, PresentationAdapter, WeakRefVirtualProxy, FeedViewAdapter. App-target only.

Full code examples: architecture-layers.md


Key Patterns Quick Reference

PatternPurpose
LoadResourcePresenter<Resource, View>Reusable loading/error/success state machine with generic mapper
WeakRefVirtualProxy<T>Break retain cycles in presenter→view binding via conditional conformance
Specification PatternProtocol-driven shared test specs across store implementations
Composition Root / ServiceCentral dependency creation and wiring (FeedService)
UI Composer (static factory)Wire presenter→adapter→view chain per feature (FeedUIComposer.feedComposedWith)
LoadResourcePresentationAdapterGeneric async loader bridging use cases to presenters with cancellation
FeedViewAdapterMaps domain models to CellController array, composes recursive loadMore
Paginated<Item>Recursive pagination with optional loadMore closure (Sendable)
Static MapperPure function for data transformation — FeedItemsMapper.map(_:from:)
Cache PolicyBusiness rule encapsulation for cache validation — FeedCachePolicy.validate(_:against:)
Local ModelCache-layer representation decoupled from domain — LocalFeedImage
Scheduler protocolAbstract store execution context for CoreData/InMemory polymorphism
CellControllerType-erased cell composition — wraps UITableViewDataSource + Delegate + Prefetching

Feature Decision Tree

Starting a new feature? Follow this path:

  1. Define the domain modelstruct in Feature layer, Hashable, Sendable
  2. Need remote data? → Endpoint enum + static mapper in API layer
  3. Need persistence? → Store protocol + local model + cache policy in Cache layer
  4. Need to display it?LoadResourcePresenter + view model struct in Presentation layer
  5. UIKit or SwiftUI? → Build view layer, conform to ResourceView protocols
  6. Wire it up → Composer + adapter + proxy in Composition Root

Step-by-step guide: feature-implementation-workflow.md


Modernization Notes

SPM over xcframework: Structure as a multi-target Swift package. Feature and API/Cache targets depend only on Foundation. UI targets import UIKit/SwiftUI. Composition target imports everything. See spm-project-structure.md.

Swift Testing over XCTest: New test suites use @Test and #expect. Shared specs become protocol extensions with @Test methods. The makeSUT() pattern and trackForMemoryLeaks adapt to Swift Testing's lifecycle. Defer to the swift-testing-expert skill for detailed patterns.

async/await: HTTPClient returns async throws. LoadResourcePresentationAdapter uses Task.immediate for synchronous-first execution. Paginated<Item>.loadMore is @Sendable () async throws -> Self. Scheduler protocol abstracts CoreData context dispatch.

SwiftUI composition: Replace WeakRefVirtualProxy with @Observable view models (SwiftUI manages lifecycle). Replace CellController type-erasure with ForEach + @ViewBuilder. Composition Root injects @Observable objects via .environment(). See SwiftUI sections in composition-and-adapters.md.


References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

architecture-design

No summary provided by upstream source.

Repository SourceNeeds Review
General

swiftui-expert

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated