sindresorhus/Defaults ? reverse-engineered prompt
Reverse engineered prompt
Build me a modern Swift library for working with UserDefaults that feels much nicer than the built in API.
I want to be able to define all my settings in one place with strong types and default values, then read and write them with simple subscript style access. It should work in normal app code and also in SwiftUI, where changing a value updates the view automatically. Please make it support common Swift types, Codable values like enums or custom structs, and also let me plug in custom serialization for special cases. I’d like observation support when values change, and if it makes sense, include iCloud syncing so settings can stay in sync across devices.
Keep it easy to use, well documented, and compatible with modern Apple platforms. If you need to, look up current Swift and Apple docs online while building it.