Skip to content

feat: add associated value and defaults macros - #7

Merged
vnixx merged 5 commits into
mainfrom
feat/defaults-associated-value-macros
Sep 12, 2026
Merged

vnixx merged 5 commits into
mainfrom
feat/defaults-associated-value-macros

Conversation

@vnixx

@vnixx vnixx commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Add SwiftSyntax macro support with the ReerKitMacros target and wire ReerKitMacroTests to import it in Xcode/SPM.
  • Add @AssociatedValue for instance associated-object get/set accessors, including built-in defaults for supported basic types.
  • Add @defaults for UserDefaults-backed get/set accessors, including static/class properties, with unlabeled key and labeled container support.
  • Use property initializers for custom macro default values; reject legacy default-value macro arguments.
  • Add ReerDefaults runtime helpers, update docs, remove CocoaPods install docs, and keep iOS/tvOS minimum support at 13.

Test Plan

  • swift build --target ReerKitMacros --explicit-target-dependency-import-check error
  • swift build --target ReerKitMacroTests
  • swift test --package-path .build/default-initializer-green.2AcK8j --filter ReerKitMacroTests
  • xcodebuild test -workspace .swiftpm/xcode/package.xcworkspace -scheme ReerKit -configuration Debug -destination 'platform=macOS' -only-testing:ReerKitMacroTests (run from temporary package copy excluding the legacy ReerKitTests target)
  • swift run --package-path .build/macro-integration MacroIntegration
  • swift test --package-path .build/macro-integration

Note: running the root Xcode package scheme directly on macOS is still blocked by the existing iOS xib resource in ReerKitTests, so macro tests were verified from a temporary package copy without that legacy test target.

… macros

- @defaults: drop the unnecessary instance-only restriction; the expanded
  accessors only reference the key and container, so type properties work
  as-is.
- @AssociatedValue: add a static/class expansion branch that hosts the
  association on the metatype object (Self.self) via the new public
  ReerAssociation runtime helper.
- Make AssociationPolicy.objcPolicy internal for ReerAssociation.
- Update macro docs, READMEs, and add macro tests for static/class var.
@vnixx
vnixx merged commit bfd6029 into main Sep 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant