Skip to content

mariusSindingAskvik/Vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Vault 🔒

iOS Continuous Integration

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.

🏗 System Architecture

The app is divided into strictly isolated concurrency domains to guarantee zero data races at compile-time.

1. The Processing Layer (@VaultProcessingActor)

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 Sendable structs (VaultRecord) before crossing actor boundaries.

2. The Persistence Layer (@ModelActor)

SwiftData is isolated completely off the Main Thread.

  • A dedicated @ModelActor manages its own background ModelContext.
  • Handles thousands of simultaneous inserts and SQLite disk writes without blocking the UI.
  • Uses a static VaultDatabaseProvider to share a thread-safe connection pool between the SwiftUI app and the system App Intents.

3. The UI Layer (@MainActor & @Observable)

A strictly isolated presentation layer.

  • The VaultViewModel safely awaits data from the background actors.
  • Uses SwiftUI's modern @Observable macro for lightweight, targeted view invalidation.
  • Renders a 120Hz scrolling dashboard using LazyVStack and inlined, concurrency-safe .visualEffect modifiers to offload matrix math directly to the GPU (Core Animation).

📊 Performance Receipts

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.

Instruments Trace

The Time Profiler Trace reveals:

  1. Zero Hangs: The top track confirms the UI never blocked.
  2. Main Thread Isolation: The @MainActor track remains completely flat during the data sync.
  3. Background Heavy Lifting: The custom @VaultProcessingActor and SwiftData @ModelActor absorb 100% of the CPU spike to parse the data and write to the SQLite disk.

🤖 System Integration

  • 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.

🧪 Modern Swift Testing

  • Fully unit-tested using Apple's new macro-based Swift Testing (@Test, @Suite).
  • Injects an in-memory ModelConfiguration to ensure fast, deterministic tests that do not pollute the simulator's disk space.
  • Validates async/await actor-hopping logic and concurrent data aggregation accuracy.

🛠 Tech Stack

  • Language: Swift 6 (Strict Concurrency Enabled)
  • Frameworks: SwiftUI, SwiftData, AppIntents, Testing
  • Target: iOS 18.0+

Getting Started

  1. Clone the repository.
  2. Open Vault.xcodeproj in Xcode 16+.
  3. Select an iOS Simulator or real device and hit Cmd + R to run.
  4. Run the test suite with Cmd + U.

About

A system-level iOS architecture demonstrating Swift 6 Strict Concurrency, actor-isolated SwiftData, and App Intents integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages