Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2026-01-14 13:40:00 -06:00
parent 8bd5a47c42
commit 40e086c591
2 changed files with 19 additions and 1 deletions

View File

@ -109,6 +109,16 @@ The app demonstrates various storage configurations:
### Platform & Sync ### Platform & Sync
- Platform availability (phoneOnly, watchOnly, all) - Platform availability (phoneOnly, watchOnly, all)
- Sync policies (never, manual, automaticSmall) - Sync policies (never, manual, automaticSmall)
- Global sync configuration (max file size) in app `init`
## Global Configuration
The app demonstrates how to configure the `LocalData` library globally during startup in `SecureStorageSampleApp.swift`:
- **Encryption**: Customized Keychain service (`SecureStorageSample`) and account (`AppMasterKey`) names to isolate the library's master encryption key from other apps.
- **Sync**: Set a custom `maxAutoSyncSize` of 50KB to control which data is automatically synchronized to the Apple Watch, overriding the library's 100KB default.
This approach centralizes infrastructure settings and avoids hardcoding environment-specific values within individual storage keys.
## Dependencies ## Dependencies

View File

@ -13,13 +13,21 @@ struct SecureStorageSampleApp: App {
init() { init() {
_ = WatchConnectivityService.shared _ = WatchConnectivityService.shared
Task { Task {
// Configure encryption constants for the app // 1. Global Encryption Configuration
// We isolate our library's master key in the Keychain by providing a specific service
// and account name. This prevents conflicts with other apps using the same library.
let config = EncryptionConfiguration( let config = EncryptionConfiguration(
masterKeyService: "SecureStorageSample", masterKeyService: "SecureStorageSample",
masterKeyAccount: "AppMasterKey" masterKeyAccount: "AppMasterKey"
) )
await StorageRouter.shared.updateEncryptionConfiguration(config) await StorageRouter.shared.updateEncryptionConfiguration(config)
// 2. Global Sync Configuration
// Overriding the default 100KB limit for automatic Watch sync to 50KB.
// This demonstrates how to tune performance for low-bandwidth scenarios.
let syncConfig = SyncConfiguration(maxAutoSyncSize: 50_000)
await StorageRouter.shared.updateSyncConfiguration(syncConfig)
do { do {
try await StorageRouter.shared.registerCatalog(AppStorageCatalog.self) try await StorageRouter.shared.registerCatalog(AppStorageCatalog.self)
} catch { } catch {