# clean-architecture-swiftui

> Sample SwiftUI app demonstrating Clean Architecture with modern Swift patterns

An open-source reference project by Alexey Naumov illustrating how to implement Clean Architecture in SwiftUI applications. It demonstrates clear separation of concerns across presentation, business logic, and data layers using modern Apple tooling like SwiftData, async/await, and Swift Testing.

Website: https://github.com/nalexn/clean-architecture-swiftui

## What it is for

- Structure production SwiftUI apps with separated presentation and data layers
- Study best practices for SwiftData persistence and async/await networking
- Implement programmatic navigation and deep linking in SwiftUI
- Set up comprehensive unit and UI tests using ViewInspector and Swift Testing

## Features

- Decoupled Presentation, Business Logic (Interactors), and Data Access (Repositories) layers
- Centralized AppState acting as a single source of truth
- Native dependency injection using SwiftUI Environment
- Data persistence powered by SwiftData
- Networking layer built using async/await
- Programmatic navigation supporting deep linking
- Unit and UI test coverage with Swift Testing and ViewInspector

## Pricing

Open source

## Details

- Type: GitHub repo
- Category: [Development](https://xiry.app/topics/development.md)
- Open source: yes
- Platforms: iOS, macOS
- For: iOS and macOS developers building SwiftUI applications
- Alternative to: The Composable Architecture (TCA)
- Tags: swift, swiftui, clean architecture, swiftdata, ios, testing

## Why it was saved

- [@nallexn, 8 December 2024](https://x.com/nallexn/status/1865828903350403544): A canonical reference for structuring SwiftUI apps with Clean Architecture, recently revamped to modern tooling: SwiftData for persistence, async/await replacing Combine, Swift Testing replacing XCTest, and @main App lifecycle.

## Related

- [Any Distance Goes Open Source](https://xiry.app/resources/any-distance-goes-open-source): Deep-dive writeup and open-source release of the Apple Design Award–winning fitness tracker. (Article or course, Free)
- [Animated Loading Button in SwiftUI](https://xiry.app/resources/animated-loading-button-in-swiftui): Pattern for building a multi-state morphing button in SwiftUI (Tip, Free)
- [Chat UI Architecture on iOS: SwiftUI List to UICollectionView](https://xiry.app/resources/chat-ui-architecture-on-ios-swiftui-list-to-uicollectionview): Engineering guide for building high-performance, streaming-friendly iOS chat message lists. (Tip, Free)
- [Add Apple Docs to Cursor Composer](https://xiry.app/resources/add-apple-docs-to-cursor-composer): Index official Apple documentation as reference docs inside Cursor's AI composer (Tip, Free)
- [DIY iPhone Device Farm Setup](https://xiry.app/resources/diy-iphone-device-farm-setup): Hardware and software workflow for batch-controlling dozens of physical iPhones (Tip)
- [Phone Farm iOS](https://xiry.app/resources/phone-farm-ios): Self-hosted iOS device farm with live browser control and workflow automation. (GitHub repo, Open source)

Updated 10 October 2026. Page: https://xiry.app/resources/clean-architecture-swiftui

Make your own library: Xiry takes your saved reels, tweets, Reddit bookmarks and Watch Later videos, makes them searchable and pulls the useful stuff out, like this library. It's invite-only for now; join the waitlist at https://xiry.app/#waitlist.
