Skip to main content

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
Why SwiftUI?
  • Declarative UI with automatic updates
  • Native macOS look and feel
  • Excellent performance with @Observable
  • Built-in drag-and-drop, context menus, and more

Key SwiftUI Features Used

Swift 6’s new observation system replaces ObservableObject:
  • No manual @Published wrappers
  • Better performance (fine-grained tracking)
  • Cleaner code
View model is injected at the root and accessed throughout the hierarchy:
Native drag-and-drop with onDrop modifier:
Right-click menus on objects:

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 icon
  • NSPopover - Floating panel
  • NSHostingController - Bridge to SwiftUI
  • NSOpenPanel - File picker
  • NSPasteboard - Clipboard operations
  • NSCache - Memory caching

Networking

URLSession

All HTTP requests use Foundation’s URLSession with async/await:
Services/R2UploadService.swift

async/await

Modern concurrency instead of callbacks

Progress Tracking

URLSessionTaskDelegate for upload progress

File Uploads

upload(for:fromFile:) for efficient streaming

Custom Delegates

Per-session delegates for progress callbacks

S3-Compatible API

Cloudflare R2 implements the AWS S3 API:
Upload a file:
List files and folders:
Returns XML with <Contents> (files) and <CommonPrefixes> (folders).
Delete a file:
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
Security consideration: Credentials are stored in plain text in UserDefaults. For a personal tool this is acceptable, but production apps should use the macOS Keychain.

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:
Every I/O operation is async:
Multiple uploads/deletes run concurrently:
Uploads can be cancelled:
All UI updates run on the main thread:
Thread-safe caching:

Sendable Types

All types crossing actor boundaries are Sendable:
nonisolated enum services can be called from any actor without await.

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
This keeps the codebase simple, secure, and maintainable.

Summary

Next Steps

Architecture

Understand the MVVM pattern and concurrency model

Project Structure

Explore the directory layout and file organization