Summary: - Sources: add LocalData.swift, Models, Protocols (+1 more) - Tests: add tests for LocalDataTests.swift - Docs: add docs for Proposal, README - Config: add Package - Other: add .gitignore Stats: - 19 files changed, 814 insertions(+)
1.2 KiB
1.2 KiB
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.