Language & Platform
Swift 6
Modern Swift with strict concurrency checking
macOS 15.0+
Leverages latest macOS APIs and SwiftUI features
Xcode 16+
Built with the latest Xcode toolchain
~4,700 LOC
Pure Swift codebase, no Objective-C
UI Frameworks
SwiftUI (Primary)
r2Vault’s entire interface is built with SwiftUI:ContentView.swift
Key SwiftUI Features Used
@Observable Macro
@Observable Macro
Swift 6’s new observation system replaces
ObservableObject:- No manual
@Publishedwrappers - Better performance (fine-grained tracking)
- Cleaner code
Environment Injection
Environment Injection
View model is injected at the root and accessed throughout the hierarchy:
Drag and Drop
Drag and Drop
Native drag-and-drop with
onDrop modifier:AppKit (Menu Bar)
While SwiftUI handles the main interface, AppKit is used for menu bar functionality:Services/MenuBarManager.swift
AppKit APIs used:
NSStatusBar/NSStatusItem- Menu bar iconNSPopover- Floating panelNSHostingController- Bridge to SwiftUINSOpenPanel- File pickerNSPasteboard- Clipboard operationsNSCache- Memory caching
Networking
URLSession
All HTTP requests use Foundation’sURLSession with async/await:
Services/R2UploadService.swift
async/await
Modern concurrency instead of callbacks
Progress Tracking
URLSessionTaskDelegate for upload progressFile Uploads
upload(for:fromFile:) for efficient streamingCustom Delegates
Per-session delegates for progress callbacks
S3-Compatible API
Cloudflare R2 implements the AWS S3 API:PUT Object
PUT Object
Upload a file:
ListObjectsV2
ListObjectsV2
List files and folders:Returns XML with
<Contents> (files) and <CommonPrefixes> (folders).DELETE Object
DELETE Object
Delete a file:
HEAD Bucket
HEAD Bucket
Test connection:
Cryptography
CryptoKit
Apple’s native cryptography framework handles AWS Signature V4:Services/AWSV4Signer.swift
SHA-256
For payload hashing and canonical request digests
HMAC-SHA256
For signature derivation (AWS Signature V4)
SymmetricKey
Type-safe key handling
Zero Dependencies
No third-party crypto libraries
Data Persistence
UserDefaults
Simple key-value storage for credentials and history:Services/KeychainService.swift
Services/UploadHistoryStore.swift
File System (Disk Cache)
Thumbnails are cached to disk in the user’s cache directory:Services/ThumbnailCache.swift
Concurrency
Structured Concurrency
All async work uses Swift 6’s structured concurrency:async/await
async/await
Every I/O operation is async:
TaskGroup (Parallel Execution)
TaskGroup (Parallel Execution)
Multiple uploads/deletes run concurrently:
Task Cancellation
Task Cancellation
Uploads can be cancelled:
@MainActor
@MainActor
All UI updates run on the main thread:
Actor Isolation
Actor Isolation
Thread-safe caching:
Sendable Types
All types crossing actor boundaries areSendable:
Media Handling
UniformTypeIdentifiers
Determines MIME types for uploads:ViewModels/AppViewModel.swift
AVFoundation
Generates video thumbnails:Services/ThumbnailCache.swift
QuickLook
Prevews files directly from R2:Services/QuickLookCoordinator.swift
XML Parsing
XMLParser (Foundation)
Custom delegate-based parser for S3 XML responses:Services/R2BrowseService.swift
S3’s ListObjectsV2 returns XML, not JSON. A custom parser extracts files (
<Contents>) and folders (<CommonPrefixes>).Developer Tools
Git
Version control with GitHub
Xcode
IDE with Swift 6 support
GitHub Actions
CI/CD for automated releases
sparkle-project
Auto-update framework (future)
Notable Absences
Zero third-party dependenciesr2Vault is built entirely with native Apple frameworks:
- No CocoaPods
- No Swift Package Manager dependencies
- No external SDKs
Summary
Next Steps
Architecture
Understand the MVVM pattern and concurrency model
Project Structure
Explore the directory layout and file organization