From 9ad66f21408deb0bd60b56867773f7185478166b Mon Sep 17 00:00:00 2001 From: mission-agi Date: Sat, 14 Mar 2026 22:10:07 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20production=20readiness=20=E2=80=94=20aut?= =?UTF-8?q?omatic=20signing=20+=20guard=20debug=20prints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enable CODE_SIGN_STYLE: Automatic in project.yml for device deployment - Wrap LocalStore print() statements in #if DEBUG to prevent console leakage in release builds --- apps/HeartCoach/Shared/Services/LocalStore.swift | 6 ++++++ apps/HeartCoach/project.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/apps/HeartCoach/Shared/Services/LocalStore.swift b/apps/HeartCoach/Shared/Services/LocalStore.swift index 2af2382a..011606b8 100644 --- a/apps/HeartCoach/Shared/Services/LocalStore.swift +++ b/apps/HeartCoach/Shared/Services/LocalStore.swift @@ -299,13 +299,17 @@ public final class LocalStore: ObservableObject { // Encryption unavailable — do NOT fall back to plaintext for health data. // Data is dropped rather than stored unencrypted. The next successful // save will restore it. This protects PHI at the cost of temporary data loss. + #if DEBUG print("[LocalStore] ERROR: Encryption unavailable for key \(key.rawValue). Data NOT saved to protect health data privacy.") + #endif #if DEBUG assertionFailure("CryptoService.encrypt() returned nil for key \(key.rawValue). Fix Keychain access or mock CryptoService in tests.") #endif } } catch { + #if DEBUG print("[LocalStore] ERROR: Failed to encode \(T.self) for key \(key.rawValue): \(error)") + #endif } } @@ -342,10 +346,12 @@ public final class LocalStore: ObservableObject { // Both encrypted and plain-text decoding failed — data is corrupted // or from an incompatible schema version. Remove the bad entry so the // app can start fresh instead of crashing on every launch. + #if DEBUG print( "[LocalStore] WARNING: Removing unreadable \(T.self) " + "from key \(key.rawValue). Stored data was corrupted or incompatible." ) + #endif defaults.removeObject(forKey: key.rawValue) return nil } diff --git a/apps/HeartCoach/project.yml b/apps/HeartCoach/project.yml index d1bef5dc..fb6bb71d 100644 --- a/apps/HeartCoach/project.yml +++ b/apps/HeartCoach/project.yml @@ -22,6 +22,7 @@ settings: SWIFT_VERSION: "5.9" ENABLE_USER_SCRIPT_SANDBOXING: true DEAD_CODE_STRIPPING: true + CODE_SIGN_STYLE: Automatic ############################################################ # Targets