Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

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

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. UserDefaults

UserDefaults

MITSwift0.3.2

A lightweight Swift library providing a simple, strongly typed wrapper for UserDefaults using Codable.

GitHubGitHub
1.4k stars91 forks0 contributors

What is UserDefaults?

DefaultsKit is a Swift library that provides a simple, strongly typed wrapper for Apple's UserDefaults. It leverages Swift's Codable protocol to serialize and deserialize complex objects, eliminating the need for manual type casting and reducing boilerplate code in iOS, macOS, and tvOS applications.

Target Audience

Swift developers building apps for Apple platforms (iOS, macOS, tvOS) who need a type-safe and efficient way to store user preferences and app state persistently.

Value Proposition

Developers choose DefaultsKit for its minimal code footprint, compile-time type safety, and seamless integration with Codable, making it a more reliable and developer-friendly alternative to raw UserDefaults.

Overview

Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS

Use Cases

Best For

  • Storing user preferences with type safety in Swift apps
  • Persisting Codable structs and enums to UserDefaults
  • Reducing boilerplate code for UserDefaults management
  • Ensuring compile-time safety when accessing stored values
  • Handling nested objects and collections in persistent storage
  • Simplifying migration from raw UserDefaults to a type-safe solution

Not Ideal For

  • Apps requiring iCloud synchronization or cross-device data syncing for user preferences
  • Projects that need to store large, complex datasets beyond UserDefaults' practical limits
  • Teams looking for a storage solution with built-in data migration and versioning tools
  • Applications that require advanced querying or relational data management

Pros & Cons

Pros

Compile-Time Type Safety

Keys are generic over value types, preventing type mismatches at compile time, as highlighted in the README's examples with strongly typed keys.

Seamless Codable Integration

Automatically serializes and deserializes any Codable-conforming object, eliminating manual JSON handling for complex structs and enums.

Minimal Code Footprint

Implemented in fewer than 100 lines of code, making it lightweight and easy to integrate without adding bloat to your project.

Efficient Existence Checks

The has() method checks key existence without deserializing values, saving performance for large or nested objects as noted in the README.

Cons

Inherits UserDefaults Limitations

Tied to UserDefaults' constraints, such as size limits and lack of thread-safety guarantees, which can be problematic for scaling or concurrent access.

No Migration Assistance

Does not provide tools for handling schema changes or data migrations, requiring manual effort when app requirements evolve.

Limited to Codable Types

Requires all stored data to conform to Codable, which may necessitate additional work for non-Codable objects or custom serialization needs.

Frequently Asked Questions

Quick Stats

Stars1,440
Forks91
Contributors0
Open Issues4
Last commit1 year ago
CreatedSince 2017

Tags

#ios#codable#userdefaults#swift4#tvos#persistent-storage#type-safe#mobile-development#swift#macos#swift-framework

Built With

C
Codable
S
Swift

Included in

iOS51.7kSwift26.0k
Auto-fetched 9 hours 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,727
Forks1,984
Last commit1 day ago
RealmRealm

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

Stars16,613
Forks2,238
Last commit2 months ago
FMDBFMDB

A Cocoa / Objective-C wrapper around SQLite

Stars13,835
Forks2,731
Last commit5 months ago
WCDBWCDB

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

Stars11,634
Forks1,499
Last commit5 months 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