Skip to content

Conversation

@couchdeveloper
Copy link
Owner

Overview

This PR significantly enhances the macro system to provide more flexibility and better code generation.

Key Changes

Enhanced @Settings Macro

The @Settings macro now generates the same infrastructure as AppSettingValues:

  • Thread-safe Config struct with OSAllocatedUnfairLock
  • Dynamic store and prefix properties with getters/setters
  • Proper locking for concurrent access

Standalone @setting Support

@Setting can now be used without requiring @Settings on the container:

// Works without @Settings!
enum MyDefaults {
    @Setting static var count: Int = 0
}

Type-Safe Container Resolution
Introduced __ContainerResolver using Swift's conditional conformance:

Automatically detects if container conforms to __Settings_Container
Falls back to UserDefaults.standard with empty prefix if not
Type resolution happens at compile time (zero runtime overhead)
Improved Nested Container Support
Fixed qualified name generation for nested containers:

Correctly generates names like "Profile::setting"
Works for both direct nesting and extension-based nesting

Breaking Changes

None - all existing code continues to work unchanged.

@couchdeveloper couchdeveloper added the enhancement New feature or request label Dec 11, 2025
@couchdeveloper couchdeveloper merged commit a6ffab0 into main Dec 11, 2025
2 checks passed
@couchdeveloper couchdeveloper deleted the improveSettingsMacro branch December 11, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants