A high-performance iOS application demonstrating system-level architecture using Swift 6 Strict Concurrency, SwiftData, and Apple Intelligence / App Intents.
This project was built to solve a specific engineering challenge: safely aggregating massive amounts of concurrent data (10,000+ records) from multiple simulated network sources and persisting it to a local SQLite database, all without dropping a single frame in the SwiftUI rendering loop.
The app is divided into strictly isolated concurrency domains to guarantee zero data races at compile-time.
Heavy lifting is offloaded to a custom Global Actor.
- Utilizes Structured Concurrency (
TaskGroup) to fetch 10,000 simulated records across three parallel network streams. - Implements
Task.checkCancellation()to immediately halt expensive processing if the user navigates away, optimizing battery life. - Uses the DTO (Data Transfer Object) Pattern to map non-Sendable database models into strictly
Sendablestructs (VaultRecord) before crossing actor boundaries.
SwiftData is isolated completely off the Main Thread.
- A dedicated
@ModelActormanages its own backgroundModelContext. - Handles thousands of simultaneous inserts and SQLite disk writes without blocking the UI.
- Uses a static
VaultDatabaseProviderto share a thread-safe connection pool between the SwiftUI app and the system App Intents.
A strictly isolated presentation layer.
- The
VaultViewModelsafely awaits data from the background actors. - Uses SwiftUI's modern
@Observablemacro for lightweight, targeted view invalidation. - Renders a 120Hz scrolling dashboard using
LazyVStackand inlined, concurrency-safe.visualEffectmodifiers to offload matrix math directly to the GPU (Core Animation).
To prove the efficacy of the strict concurrency architecture, I ran a stress test generating and persisting 10,000 records simultaneously while aggressively scrolling the UI.
The Time Profiler Trace reveals:
- Zero Hangs: The top track confirms the UI never blocked.
- Main Thread Isolation: The
@MainActortrack remains completely flat during the data sync. - Background Heavy Lifting: The custom
@VaultProcessingActorand SwiftData@ModelActorabsorb 100% of the CPU spike to parse the data and write to the SQLite disk.
- App Intents: Fully integrated with Siri and Shortcuts. Users can ask, "Hey Siri, get my Vault balance," which spins up the background database connection and returns the aggregated value without launching the app.
- Fully unit-tested using Apple's new macro-based Swift Testing (
@Test,@Suite). - Injects an in-memory
ModelConfigurationto ensure fast, deterministic tests that do not pollute the simulator's disk space. - Validates
async/awaitactor-hopping logic and concurrent data aggregation accuracy.
- Language: Swift 6 (Strict Concurrency Enabled)
- Frameworks: SwiftUI, SwiftData, AppIntents, Testing
- Target: iOS 18.0+
- Clone the repository.
- Open
Vault.xcodeprojin Xcode 16+. - Select an iOS Simulator or real device and hit
Cmd + Rto run. - Run the test suite with
Cmd + U.
