💾 GoodPersistence is an iOS library that simplifies caching data in keychain and UserDefaults. Using a property wrapper, it reduces the complexity of implementing caching mechanisms, making it easier for developers to focus on app functionality. Compatible with latest Swift and supports all iOS devices. Easy to install with SPM.
I am unable to use KeychainWrapper. It gives me Cannot find 'KeychainWrapper' in scope error. Xcode shows this class as unavailable in current scope. @KeychainValue decorator works correctly though. I imported required modules.
I did the Project Clean / Clean Derived Data / Xcode Restart.
Describe the bug
In case we are subscribed to valuePublisher, after first error passed to subject, subject completes and is not reinitialized. After error we are unable to receive new values passed to keychain.
To Reproduce
Steps to reproduce the behavior:
Create Keychain
Subscribe to valuePublisher
Try to force error inside keychain property
Pass valid value to property
New value is not receiver in valuePublisher
Expected behavior
After receiving error, I am able to receive next values.
Additional context
Suggested solution:
private let newSubject: PassthroughSubject<Either<T, KeychainError>, Never> = PassthroughSubject()
private let newSubject: PassthroughSubject<Event<T, KeychainError>, Never> = PassthroughSubject()
In SwiftUI there is a property wrapper @AppStorage that gives developer the ability to store raw data (Strings, numbers, booleans, URLs) in cache. User interface then automatically updates itself when the underlying data change.
It should be possible to integrate the same functionality using DynamicProperty protocol into GoodPersistence property wrappers to extend system functionality to save any Codable data as JSON string, automatically (de)serialize when required, and auto-update the UI on property change.
It might be possible to integrate the same functionality for values stored in keychain also.