Go to file
Matt Bruce b9dca68c5d Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config
Summary:
- Sources: LocalData.swift, Models, Protocols, Services
- Tests: LocalDataTests.swift
- Docs: Proposal, README
- Config: Package
- Other: .gitignore
- Added symbols: enum StorageKeys, struct AnyCodable, func encode, enum FileDirectory, func url, enum KeychainAccessControl (+49 more)

Stats:
- 19 files changed, 814 insertions(+)
2026-01-18 14:53:25 -06:00
Sources/LocalData Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00
Tests/LocalDataTests Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00
.gitignore Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00
Package.swift Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00
Proposal.md Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00
README.md Update LocalData.swift, Models, Protocols (+1 more) + tests + docs + config 2026-01-18 14:53:25 -06:00

LocalData

LocalData provides a typed, discoverable namespace for persisted app data across UserDefaults, Keychain, and file storage with optional encryption.

What ships in the package

  • StorageKey protocol and StorageKeys namespace for app-defined keys
  • StorageRouter actor (StorageProviding) with async set/get/remove
  • StorageDomain options for user defaults, keychain, and file storage
  • SecurityPolicy options for none, keychain, or encrypted data
  • Serializer for JSON, property lists, raw Data, or custom encode and decode
  • PlatformAvailability and SyncPolicy metadata for watch behavior
  • AnyCodable utility for structured payloads

Usage

Define keys in your app by extending StorageKeys. Use StorageRouter.shared to set, get, and remove values. See SecureStorgageSample/SecureStorgageSample for working examples.

Sync behavior

StorageRouter can call WCSession.updateApplicationContext when SyncPolicy is manual or automaticSmall and availability is all or phoneWithWatchSync. The app is responsible for activating WCSession and handling incoming updates.

Platforms

  • iOS 17+
  • watchOS 10+

Notes

  • LocalData does not include sample key definitions or models.
  • Keys should be stable and unique per domain or service.