attributed-string
AttributedString
Type-safe, value-semantic styled text on Apple platforms (Foundation, iOS 15+). The deep API reference — creation, every attribute scope, Markdown, custom attributes, AttributeContainer, runs, character/unicode views, Codable, SwiftUI Text, the iOS 26 rich-text TextEditor, and NSAttributedString conversion — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics. For surrounding SwiftUI work (layout, state, view composition), use swiftui-pro.
Dials
Set these explicitly at the start; they change what "correct" means.
RENDERER—swiftui(default; SwiftUIText/TextEditor, use.swiftUIscope attributes:Color,Font) ·uikit(UILabel/UITextViewviaNSAttributedString, use.uiKitscope:UIColor,UIFont,NSParagraphStyle). The scope you author must match the renderer or attributes silently drop.SOURCE—programmatic(build runs in code via attributes/AttributeContainer) ·markdown(parse withinit(markdown:options:)— pick theinterpretedSyntaxdeliberately) ·editable(iOS 26TextEditor(text: $attributedString)for user-authored rich text).CUSTOM_ATTRS—none(system scopes only) ·custom(your ownAttributedStringKey+AttributeScope; needed for domain data,Codableround-trips, and^[text](attr:)Markdown).
When to use
Building or reviewing any styled-text value: a Text with mixed styling, Markdown rendered in-app, a rich-text editor, attributed labels, or persisted styled content. If the work is general SwiftUI (layout, navigation, state) with no attributed text, use swiftui-pro instead.