A Swift library for easy and safe file persistence of Codable structs, images, and data on iOS.
Disk is a Swift library that simplifies file persistence on iOS by providing an intuitive API for saving and retrieving Codable structs, images, and data. It abstracts the complexities of the iOS file system, ensuring compliance with Apple's storage guidelines while eliminating manual encoding/decoding work. Developers can persist data to appropriate directories like Documents or Caches with minimal code, leveraging Swift's modern Codable protocol for seamless JSON serialization.
iOS developers who need a straightforward, type-safe way to persist user data, cache network responses, or manage app files without dealing with low-level file system APIs or heavy frameworks like Core Data.
Disk offers a lightweight, focused alternative to bulkier persistence solutions by combining Swift's Codable protocol with robust file management. It enforces best practices for iOS storage, provides detailed error handling, and significantly reduces boilerplate code compared to manual methods or NSKeyedArchiver.
Easily persist structs, images, and data on iOS
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically encodes and decodes Swift structs and arrays to/from JSON with a single line of code, leveraging Swift's Codable protocol for type-safe persistence without manual work.
Provides clear abstractions for Documents, Caches, Application Support, and other directories, ensuring strict adherence to Apple's iOS Data Storage Guidelines for proper iCloud backup behavior.
Throws comprehensive errors with descriptions, failure reasons, and recovery suggestions, as shown in the debugging section, aiding robust debugging and issue resolution.
The README highlights that Disk is significantly faster than alternatives like NSKeyedArchiver, reducing boilerplate code and offering efficient file system operations.
Disk operations are synchronous, requiring developers to manually implement async handling with Grand Central Dispatch to avoid blocking the main thread, as admitted in the Large Files section.
Only supports Codable structs, UIImage, Data, and their arrays, lacking built-in functionality for complex object graphs, relational data, or other custom types.
Unlike modern libraries, Disk does not offer native asynchronous methods, forcing developers to manage concurrency themselves, which can increase code complexity.