Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. Defaults

Defaults

MITSwift9.0.8

A Swifty and modern type-safe wrapper for UserDefaults with SwiftUI support and iCloud sync.

Visit WebsiteGitHubGitHub
2.5k stars162 forks0 contributors

What is Defaults?

Defaults is a Swift library that wraps Apple's UserDefaults API with a type-safe, modern interface. It solves the problem of verbose and error-prone UserDefaults usage by allowing developers to declare strongly-typed keys with default values upfront. The library adds features like SwiftUI property wrappers, observation, and support for Codable types, making persistent storage simpler and more robust.

Target Audience

Swift developers building iOS, macOS, tvOS, watchOS, or visionOS apps who need a better way to handle persistent user preferences and app state. It's especially useful for developers using SwiftUI who want reactive updates when UserDefaults values change.

Value Proposition

Developers choose Defaults because it eliminates the stringly-typed nature of raw UserDefaults, reduces boilerplate, and provides a seamless SwiftUI experience. Its production-ready reliability, extensive type support, and iCloud synchronization offer a comprehensive solution that goes beyond Apple's built-in @AppStorage property wrapper.

Overview

💾 Swifty and modern UserDefaults

Use Cases

Best For

  • Storing user preferences in a type-safe way across app launches
  • SwiftUI apps that need reactive updates when settings change
  • Syncing simple app state between devices via iCloud
  • Replacing verbose UserDefaults code with a clean, declarative API
  • Storing Codable enums or custom types in UserDefaults
  • Observing specific UserDefaults keys for changes without NotificationCenter boilerplate

Not Ideal For

  • Apps targeting iOS 13 or earlier, as Defaults requires iOS 14+ and similar modern OS versions
  • Projects where minimizing third-party dependencies is critical, since Defaults adds an external library instead of using built-in solutions
  • Use cases involving large, structured datasets requiring complex queries or transactions, as UserDefaults is designed for simple key-value storage
  • Teams exclusively using @AppStorage for basic SwiftUI needs who don't require additional features like observation or Codable support

Pros & Cons

Pros

Compile-Time Type Safety

Declares types and default values upfront using strongly-typed keys, eliminating stringly-typed errors and ensuring safety at compile time, as emphasized in the README.

SwiftUI Reactivity

Provides a @Default property wrapper that automatically updates views when UserDefaults values change, seamlessly integrating with SwiftUI's state management for reactive UIs.

Broad Codable Support

Supports storage of any Codable value, including enums and custom types, with built-in serialization, reducing boilerplate compared to manual UserDefaults handling.

Built-in Observation

Enables easy observation of key changes without NotificationCenter boilerplate, facilitating reactive programming patterns in both SwiftUI and non-SwiftUI contexts.

Cons

Legacy OS Exclusion

Only compatible with macOS 11+, iOS 14+, and newer, which excludes apps that need to support older operating systems and devices.

Initial Setup Overhead

Requires defining keys in a Defaults.Keys extension, adding boilerplate code that might be unnecessary for very simple storage needs compared to raw UserDefaults.

Third-Party Dependency Risk

Introduces an external library that must be maintained and updated, whereas Apple's @AppStorage is built-in and less prone to breaking changes or compatibility issues.

Frequently Asked Questions

Quick Stats

Stars2,467
Forks162
Contributors0
Open Issues19
Last commit2 months ago
CreatedSince 2018

Tags

#ios#codable#storage#userdefaults#nsuserdefaults#swift-package-manager#swifty#property-wrapper#persistent-storage#type-safe#swift-package#swiftui#swiftui-components#swift#macos#icloud-sync

Built With

S
Swift

Links & Resources

Website

Included in

iOS51.7kSwift26.0k
Auto-fetched 1 day ago

Related Projects

MMKVMMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, POSIX, and OHOS.

Stars18,610
Forks1,982
Last commit6 days ago
RealmRealm

Realm is a mobile database: a replacement for Core Data & SQLite

Stars16,608
Forks2,223
Last commit2 months ago
WCDBWCDB

WCDB is a cross-platform database framework developed by WeChat.

Stars11,493
Forks1,498
Last commit1 month ago
SQLite.swiftSQLite.swift

A type-safe, Swift-language layer over SQLite3.

Stars10,161
Forks1,617
Last commit4 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub