MockUserDefaults

2.5.0

Mocking UserDefaults for tests
417-72KI/MockUserDefaults

What's New

2.5.0

2026-05-01T14:38:22Z

Important

  1. CocoaPods support has been finished. Use SwiftPM instead.

What's Changed

  • Pin kishikawakatsumi/xcresulttool action to 2b37f11 by @renovate[bot] in #64
  • Revert "Pin kishikawakatsumi/xcresulttool action to 2b37f11" by @417-72KI in #65
  • Update actions/download-artifact action to v5 by @renovate[bot] in #68
  • Update actions/checkout action to v5 by @renovate[bot] in #69
  • Update actions/download-artifact action to v6 by @renovate[bot] in #71
  • Update actions/upload-artifact action to v5 by @renovate[bot] in #72
  • Update actions/checkout action to v6 by @renovate[bot] in #73
  • Update actions/download-artifact action to v7 by @renovate[bot] in #74
  • Update actions/upload-artifact action to v6 by @renovate[bot] in #75
  • Update actions/download-artifact action to v8 by @renovate[bot] in #76
  • Update actions/upload-artifact action to v7 by @renovate[bot] in #77
  • Pin dependencies by @renovate[bot] in #80
  • Drop CocoaPods support by @417-72KI in #79
  • Update actions/github-script action to v9 by @renovate[bot] in #78
  • Xcode 26 support by @417-72KI in #82
  • Pin slidoapp/xcresulttool action to 9c51e32 by @renovate[bot] in #83

Full Changelog: 2.4.0...2.5.0

MockUserDefaults

Test GitHub release GitHub license

MockUserDefaults is a simple replacement for NSUserDefaults/UserDefaults to make test easier.

Installation

SwiftPM (recommended)

.package(url: "https://github.com/417-72KI/MockUserDefaults.git", from: "2.5.0"),

CocoaPods

Warning

CocoaPods support is no longer provided. Please use SwiftPM instead.

pod 'MockUserDefaults'

Usage

Objective-C

NSUserDefaults *userDefaults = [NSUserDefaults mockedUserDefaults];
[userDefaults setObject:@"string" forKey:@"key"];

XCTAssertEqualObjects([userDefaults objectForKey:@"key"], @"string");

Swift

let userDefaults: UserDefaults = .mock
userDefaults.set("string", forKey: "key")

XCTAssertEqual(userDefaults.string(forKey: "key"), "string")

Demo

Create project

First time

make init_demo_app

After the first time

make demo_app

Usage

  1. open MockUserDefaultsDemo.xcworkspace
  2. Build and run app (⌘+R) in iPhone / iPad Simulator
  3. Add any keys and values
  4. Run test (⌘+U) in same simulator
  5. Re-run app (⌘+R) in same simulator
  6. You can see that the app isn't affected by the test.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri May 22 2026 21:27:50 GMT-0900 (Hawaii-Aleutian Daylight Time)