<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AttributedTextFormatting/Transferable/init(text:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI24AttributedTextFormattingOAAE12TransferableV4text2inAE10Foundation0C6StringV_AA17EnvironmentValuesVtcfc"
  },
  "title" : "init(text:in:)"
}
-->

# init(text:in:)

Create a transferable representation of an attributed string
as interpreted in a SwiftUI environment.

```
init(text: AttributedString, in environment: EnvironmentValues)
```

## Discussion

When exporting the `text` into different data formats,
the transfer representation may use the given `environment` to
resolve semantic attribute values, such as certain colors or fonts
to concrete values. This means that depending on the representation
used during transfer, some semantic information may be lost in that
step.

> Note: The transferable representation applies the
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/AttributedTextFormattingDefinition`` in the `environment` before
> exporting the content.

> SeeAlso: ``View/attributedTextFormattingDefinition(_:)-uc57``,
> ``AttributedTextValueConstraint/constrain(_:)-6cp64``

---

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)