Skip to content

Conversation

@couchdeveloper
Copy link
Owner

Changes

1. KVO-Compliant Prefix Validation

File: AppSetting.swift

  • Added automatic dot replacement in AppSettingValues.prefix setter
  • Ensures prefix remains KVO-compliant (dots are not allowed in KVO key paths)
  • Prevents runtime errors when observing UserDefaults changes

Breaking

  • UserDefaultsStore protocol now requires AnyObject conformance

Additional Detail

The observer lifecycle fix addresses a critical issue where SwiftUI views would continue observing old store instances after switching to mock stores in previews. The KVO compliance ensures prefix strings work correctly with Foundation's observation mechanism.

- Ensure prefix property is KVO compliant by replacing dots with underscores
- Fix observer lifecycle: cancel and recreate subscription when store changes
- Add AnyObject constraint to UserDefaultsStore protocol for identity comparison
- Refactor UserDefaultsStoreMock: make helper methods static
@couchdeveloper couchdeveloper added the breaking A change which result in breaking the API. This will increase the major version number by one. label Dec 10, 2025
@couchdeveloper couchdeveloper merged commit b32c53a into main Dec 10, 2025
2 checks passed
@couchdeveloper couchdeveloper deleted the improveObsercerLifeCycle branch December 10, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking A change which result in breaking the API. This will increase the major version number by one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants