From 07defd0045bf360229a0228a17ac8ff13e6758e1 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 11 Dec 2022 22:11:28 +0100 Subject: [PATCH] Fixed the initialiser of the KeychainStorage property wrapper. --- .../Property Wrappers/KeychainStorage.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/Sources/KeychainStorage/Property Wrappers/KeychainStorage.swift b/Libraries/Sources/KeychainStorage/Property Wrappers/KeychainStorage.swift index 11fc43f..34f8332 100644 --- a/Libraries/Sources/KeychainStorage/Property Wrappers/KeychainStorage.swift +++ b/Libraries/Sources/KeychainStorage/Property Wrappers/KeychainStorage.swift @@ -62,13 +62,11 @@ public struct KeychainStorage: DynamicProperty { self.keychain = keychain do { - let data = try keychain.getData(key, ignoringAttributeSynchronizable: true) - - guard let data else { - assertionFailure("The data of the '\(key)' key should have been obtained from the keychain storage.") + guard let data = try keychain.getData(key, ignoringAttributeSynchronizable: true) else { + self._value = .init(initialValue: defaultValue) return } - + do { let model = try decoder.decode(Value.self, from: data) @@ -77,7 +75,7 @@ public struct KeychainStorage: DynamicProperty { assertionFailure("The data for the '\(key)' key should have been decoded properly.") } } catch { - self._value = .init(initialValue: defaultValue) + assertionFailure("The data of the '\(key)' key should have been obtained from the keychain storage.") } }