<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StateReporting",
  "identifier" : "/documentation/StateReporting/ReportableMetadata()",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "StateReporting"
    ],
    "preciseIdentifier" : "s:14StateReporting18ReportableMetadatayycfm"
  },
  "title" : "ReportableMetadata()"
}
-->

# ReportableMetadata()

Automatically generates `ReportableMetadata` conformance for a type.

```
@attached(member, names: named(metadataDictionary)) @attached(extension, conformances: ReportableMetadata) macro ReportableMetadata()
```

## Overview

Apply `@ReportableMetadata` to a `struct` or `class` to enable generation of a `metadataDictionary`
from its stored properties. Properties with supported types (`String`, `Int`, `Double`, `Date`, `Bool`)
are included; properties with unsupported types are silently skipped. The macro generates a
`metadataDictionary` that maps each included property name to the corresponding
[`ReportableMetadataValue`](/documentation/StateReporting/ReportableMetadataValue) case.

Use [`ReportableMetadataKey(_:)`](/documentation/StateReporting/ReportableMetadataKey(_:)) to override the dictionary key for a specific property, and
[`ReportableMetadataIgnored()`](/documentation/StateReporting/ReportableMetadataIgnored()) to exclude a property entirely.

```swift
@ReportableMetadata
struct CheckoutMetadata {
    var cartItemCount: Int
    var promoCode: String?
    @ReportableMetadataKey("ts") var timestamp: Date
    @ReportableMetadataIgnored var internalToken: String
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)