A lightweight Swift library to store and retrieve Codable objects in UserDefaults with thread-safe operations.
UserDefaultsStore is a Swift library that simplifies storing and retrieving Codable objects in UserDefaults. It provides a type-safe, thread-safe API to manage persistent data for iOS, macOS, tvOS, and watchOS apps, reducing the boilerplate code needed for encoding and decoding.
Swift developers building apps for Apple platforms who need a lightweight, simple solution for persisting Codable objects in UserDefaults without complex setup.
Developers choose UserDefaultsStore for its minimalistic design, seamless Codable integration, and thread safety, offering a straightforward alternative to manual UserDefaults handling or heavier persistence frameworks.
Why not use UserDefaults to store Codable objects 😉
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Seamlessly handles encoding and decoding of any Codable object, eliminating manual JSON boilerplate as shown in the usage examples for structs like User and Laptop.
Both UserDefaultsStore and SingleUserDefaultsStore are designed for concurrent access, ensuring data consistency in multi-threaded environments without extra setup.
Leverages Swift generics and Identifiable protocol to provide compile-time safety, reducing runtime errors when storing and retrieving objects by their id.
Reduces storage to a few lines of code—just conform to Codable and Identifiable, then create a store—making it ideal for quick prototyping or simple apps.
The library is marked as deprecated with no future updates, directing users to a new library, which means potential security risks and lack of support for new Swift versions.
Version 3.0 removed features like custom encoders/decoders and snapshots, forcing existing users to refactor code during upgrades, as noted in the README.
Inherits all constraints of UserDefaults, such as storage caps for 'reasonable amounts' of data and no built-in encryption, limiting use cases for sensitive or large datasets.