From 40e086c5912c94bdd1fe3ed7e480ce7493930433 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 14 Jan 2026 13:40:00 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- README.md | 10 ++++++++++ SecureStorageSample/SecureStorageSampleApp.swift | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 246ddf5..cd9a0f2 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,16 @@ The app demonstrates various storage configurations: ### Platform & Sync - Platform availability (phoneOnly, watchOnly, all) - 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 diff --git a/SecureStorageSample/SecureStorageSampleApp.swift b/SecureStorageSample/SecureStorageSampleApp.swift index de54f6d..1a87140 100644 --- a/SecureStorageSample/SecureStorageSampleApp.swift +++ b/SecureStorageSample/SecureStorageSampleApp.swift @@ -13,13 +13,21 @@ struct SecureStorageSampleApp: App { init() { _ = WatchConnectivityService.shared 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( masterKeyService: "SecureStorageSample", masterKeyAccount: "AppMasterKey" ) 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 { try await StorageRouter.shared.registerCatalog(AppStorageCatalog.self) } catch {