LocalData/README.md
2026-01-13 21:13:17 -06:00

27 lines
1.2 KiB
Markdown

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