
Diagnose broken behavior in TextKit text editors — stale layout, crashes during editing, TextKit 1 fallback, Writing Tools failures, rendering artifacts, content loss. Use when the question starts with a symptom rather than an API name. Read the actual code before reciting causes from this skill — the patterns here are clues, not answers. Trigger on 'text disappeared', 'layout is wrong', 'editor crashed', 'fonts look weird', 'characters are clipped' even without TextKit named. Do NOT use for the complete TK1-fallback trigger catalog (txt-fallback-triggers), the invalidation model itself (txt-layout-invalidation), or severity-ranked code review findings (txt-audit).
Compare NSTextView and UITextView capabilities for porting between macOS and iOS, building Mac Catalyst editors, or planning cross-platform text features. Covers the AppKit-only stack (text tables, rulers, font/list/table/spacing panels, grammar checking, text completion, Services menu, field editor, NSText RTF I/O) and the UIKit-only stack (UITextInteraction, UITextItem interactions, UITextSelectionDisplayInteraction, UITextLoupeSession, declarative dataDetectorTypes), plus the architectural differences (scroll view, inheritance, delegate richness, Writing Tools coordinator, fallback detection). Use when porting a text editor between platforms, when a feature is missing on one side, or when scoping cross-platform work. Do NOT use for picking among SwiftUI views — see txt-view-picker.
Look up NSAttributedString.Key values, value types, and view-compatibility rules — typography, color, decoration, paragraph style, attachments, links, AppKit-only keys. Use when picking the right key, debugging an attribute that "does nothing," or checking whether an attribute survives in SwiftUI Text vs UITextView vs NSTextView. The key catalog and view-compatibility matrix change with each Foundation release; before claiming any signature is current, fetch via Sosumi (`sosumi.ai/documentation/foundation/nsattributedstring/key`). Do NOT use for the AttributedString-vs-NSAttributedString decision — see txt-attributed-string. Do NOT use for inline image/Genmoji embedding — see txt-attachments. Do NOT use for color-specific dark-mode behavior — see txt-colors.
Review Apple text code for correctness, performance, and modernization risk in a single pass with severity-ranked findings. Covers TextKit 1 fallback triggers, NSTextStorage subclass correctness (edited / changeInLength / batched edits), didProcessEditing character-mutation bugs, deprecated glyph APIs, full-document ensureLayout, missing allowsNonContiguousLayout, NSLinguisticTagger / UIMenuController deprecations, missing performEditingTransaction wrappers on TextKit 2, Writing Tools coordinator gaps (writingToolsIgnoredRangesIn, isWritingToolsActive), String-vs-NSString length confusion in range arithmetic, and main-thread storage rules. Use when a user asks to audit, scan, or review a text editor codebase, when preparing an editor for shipping, when triaging a post-release regression in TextKit code, or when a pull request needs a structured pass focused on text-specific risks.
Handle bidirectional text, right-to-left languages, mixed Arabic/Hebrew/Latin content, writing-direction APIs at every layer, and cursor/selection behavior in bidi text. Covers NSParagraphStyle.baseWritingDirection, the .writingDirection attributed-string key with embedding/override modes, AttributedString.writingDirection, UITextInput.setBaseWritingDirection, SwiftUI .environment(\.layoutDirection), iOS 26 Natural Selection (selectedRanges), Unicode bidi controls (LRM/RLM/LRE/RLE/PDF/FSI/PDI), .natural vs .left/.right alignment, and visual vs logical order. Use when adding RTL support, debugging cursor jumps in mixed content, fixing phone numbers that reorder in Arabic context, migrating to selectedRanges, or making a custom UITextInput view bidi-correct. Trigger on Arabic, Hebrew, RTL, or "cursor moves wrong" even without bidi APIs named. Do NOT use for general localization or locale-aware formatting (out of scope for this repo).
Use Core Text directly — CTLine, CTRun, CTFramesetter, CTTypesetter, CTFont, CTRunDelegate — for glyph-level access, custom typesetting, hit testing outside a text container, font tables, or per-glyph Core Graphics rendering. Use when you need glyph IDs and positions, custom line breaking, drawing text into a CGContext, OpenType feature inspection, or inline non-text elements with custom metrics. Read the actual rendering pipeline (especially the coordinate flip) before reciting fixes — most Core Text bugs are inverted axes or attribute-key type mismatches. Do NOT use when TextKit 2 already exposes the APIs you need — see txt-textkit2.
Configure NSDataDetector, NLTagger, NLTokenizer, NLLanguageRecognizer, and NSString-bridging utilities for Apple text. Use when extracting links/phones/dates/addresses from prose, tagging part of speech or named entities, segmenting tokens or sentences, identifying language, or computing word and sentence embeddings — and whenever a String/NSRange/NSString boundary needs careful conversion. Trigger on 'detect URLs', 'find phone numbers', 'language detection', 'tokenize sentences', 'part of speech', 'sentiment analysis' even without naming any of the actual APIs. Do NOT use for choosing between Swift Regex and NSRegularExpression — that decision lives in txt-regex.
Configure Dynamic Type scaling for system and custom fonts in UIKit, AppKit, and SwiftUI — semantic text styles, UIFontMetrics, ScaledMetric, adjustsFontForContentSizeCategory, dynamicTypeSize, minimumContentSizeCategory, content-size change notifications, large content viewer. Use when text doesn't scale with the user's text-size preference, attributed strings keep their original size after a category change, custom fonts need to follow body or headline curves, layouts break at AX1-AX5, or you need to clamp the scale range for a view. Trigger on 'make text bigger', 'AX sizes', 'large text mode', 'accessibility text size', 'why isn't my custom font scaling' even without Dynamic Type named. Do NOT use for general text-editor accessibility traits or VoiceOver wiring — see txt-accessibility.
Wrap text around shapes, build multi-column or magazine layouts, and embed tables in attributed strings using NSTextContainer.exclusionPaths, linked NSTextContainer arrays, NSTextTable, NSTextTableBlock, NSTextList, and custom NSTextContainer subclasses. Covers TextKit 1 and TextKit 2 differences, the text container coordinate system, the lineFragmentRect override, and the UIKit fallback for tables via NSTextAttachmentViewProvider. Use when text needs to flow around an image, when an article needs side-by-side columns or paginated text flow, when an editor needs an in-text table, or when the question involves non-rectangular text regions. Use whenever the user mentions text wrapping, columns, or magazine layout, even if they do not name exclusion paths. Do NOT use for simple line wrapping, hyphenation, or paragraph spacing — see txt-line-breaking. Do NOT use for embedding interactive views inline — see txt-attachments.
Refresh time-sensitive Apple Text skill content against current Apple documentation via Sosumi. Walks the `references/latest-apis.md` companion file in each time-sensitive skill (txt-swiftui-texteditor, txt-writing-tools, txt-textkit2, txt-attribute-keys, txt-attributed-string), fetches the current API surface from sosumi.ai, and produces a diff report so a maintainer can review and commit. Use when a new iOS / Swift / Xcode point release ships, when the user asks to "refresh the skills against current docs", "sync against WWDC", "update the Apple text skills for the new SDK", "freshen latest-apis.md", or any maintenance trigger. Trigger after WWDC, after Xcode 26.x bumps, or whenever an agent author notices skill content drifting from the current API surface — even when 'maintenance' isn't named. Do NOT use for authoring new skills or rewriting existing ones — that's the job of the per-skill rewrite workflow described in AGENTS.md.
Measure rendered size of strings and attributed strings, size views to fit text content, and read per-line metrics from NSLayoutManager and NSTextLayoutManager. Covers boundingRect with NSStringDrawingOptions, NSStringDrawingContext for auto-shrink, sizeThatFits, intrinsicContentSize, usedRect, enumerateLineFragments, usageBoundsForTextContainer, line-fragment typographic bounds, and the lineFragmentPadding/textContainerInset arithmetic that makes measurements match what UITextView actually renders. Use when text clips by a pixel, boundingRect returns a single-line size for multi-line text, a self-sizing UITextView refuses to size, intrinsicContentSize is wrong, or the user needs line counts. Do NOT use for paragraph style, hyphenation, or line height — see txt-line-breaking. Do NOT use for layout invalidation timing — see txt-layout-invalidation.
Subclass and reason about NSTextStorage, NSTextContentStorage, and NSTextContentManager. Covers the editing lifecycle (beginEditing / edited / processEditing / fixAttributes), the four required primitives for an NSTextStorage subclass, NSTextStorageDelegate hooks (willProcessEditing vs didProcessEditing), edit batching, the TextKit 2 performEditingTransaction wrapper, NSTextContentStorageDelegate for display-only paragraph rewriting, and when to subclass NSTextContentManager directly for non-attributed-string backing stores. Use when implementing a custom backing store (rope, piece table, gap buffer), wiring syntax highlighting through delegate callbacks, debugging missing edited() calls, or routing edits through the TextKit 2 transaction model. Do NOT use for symptom-driven debugging — see txt-textkit-debug.
Customize copy, cut, and paste in text editors — UIPasteboard and NSPasteboard reads and writes, NSItemProvider type negotiation, format stripping and rich-text sanitization on paste, NSTextAttachment handling for pasted images, custom UTType identifiers for round-tripping app-specific formats. Use when paste brings unwanted fonts and colors, copies should write multiple representations, custom formats need to round-trip, pasted images should land as inline attachments, or programmatic paste is bypassing typing attributes. Trigger on 'paste brings in fonts/styles I don't want', 'copy with formatting', 'cmd-c isn't doing the right thing', or any clipboard-related editor question even without UIPasteboard mentioned. Do NOT use for drag-and-drop (see txt-drag-drop).
Look up working code snippets for common text-view features — placeholder text, character/word limits, auto-growing height, search highlighting, link/data detection, line numbers, custom cursor color, scroll-to-range. Use when the user asks "how do I…" about a small, well-scoped UITextView/NSTextView or NSAttributedString task and you need a copy-paste recipe rather than architecture guidance. Trigger on casual 'how do I add line numbers / a placeholder / a character limit / a custom cursor color' phrasings even when no API name appears. Do NOT use for picking between TextKit 1 and TextKit 2 (txt-textkit-choice), choosing a text view (txt-view-picker), or paragraph-style internals (txt-line-breaking).
Integrate Writing Tools into UITextView, NSTextView, custom UITextInput views, or fully custom editors via UIWritingToolsCoordinator. Configure writingToolsBehavior and allowedWritingToolsResultOptions, declare protected ranges via writingToolsIgnoredRangesInEnclosingRange, gate edits with isWritingToolsActive, and pause syncing in willBegin/didEnd. Trigger on 'Apple Intelligence rewrite', 'AI summarize selection', 'compose with AI', 'why won't Writing Tools appear', or 'rewrite is breaking my code blocks' even without UIWritingToolsCoordinator named. Use when Writing Tools is missing from the menu, only the panel mode appears, rewrites corrupt code blocks, the inline animation isn't running, or a custom text engine needs to adopt UIWritingToolsCoordinator. Do NOT use for diagnosing general TextKit 1 fallback symptoms — see txt-fallback-triggers.
Render and parse Markdown in SwiftUI Text and AttributedString — inline syntax that works, block-level syntax that doesn't, PresentationIntent interpretation, and custom `^[text](key:value)` attributes via MarkdownDecodableAttributedStringKey. Use when Markdown isn't rendering as expected, headings/lists are silently dropped, a `String` variable shows literal asterisks, you're choosing between native parsing and a third-party renderer, or you need block-level formatting in UITextView. Do NOT use for the AttributedString-vs-NSAttributedString decision in general — see txt-attributed-string. Do NOT use for parser/regex mechanics on non-Markdown text — see txt-regex.
Choose between AttributedString and NSAttributedString, define custom attributes via AttributeScope, and convert safely at API boundaries. Use when picking the model for new code, designing a custom attribute key (`AttributedStringKey`, `CodableAttributedStringKey`, `MarkdownDecodableAttributedStringKey`), wiring a scope so attributes round-trip across SwiftUI/UIKit, or when a conversion silently dropped data. AttributedString gains capabilities every Foundation release; before claiming a specific scope, key, or conversion overload is current, fetch via Sosumi (`sosumi.ai/documentation/foundation/attributedstring`). Do NOT use for looking up specific NSAttributedString.Key values like underline or shadow — see txt-attribute-keys. Do NOT use for Markdown parsing semantics — see txt-markdown.
Configure and reason about text layout invalidation across TextKit 1 (NSLayoutManager) and TextKit 2 (NSTextLayoutManager). Covers what triggers invalidation, the lazy-recompute model, ensureLayout / invalidateLayout / invalidateGlyphs / invalidateDisplay scoping, the editing transaction in TextKit 2, NSTextContentStorage element regeneration, viewport-driven layout updates, and why rendering attributes do not invalidate layout. Use when reasoning about how layout gets recomputed after a text edit, after a container size change, or after exclusion-path mutation. Do NOT use for symptom-driven debugging — see txt-textkit-debug. Do NOT use for fallback issues — see txt-fallback-triggers.
Embed images, custom interactive views, or Genmoji inline in attributed text via NSTextAttachment, NSTextAttachmentViewProvider, and NSAdaptiveImageGlyph. Use when an attachment renders at the wrong size or position, baseline alignment is off, a view-based attachment vanishes, Genmoji insertion fails, or copy/paste loses the image. Covers attachment bounds and baseline math, view-provider lifecycle, registration timing, and the TextKit 1 fallback that kills view providers. Read the actual storage and view-provider implementation before reciting causes; the patterns here are clues, not answers.
Configure NSParagraphStyle line wrapping, hyphenation, truncation, line height, paragraph spacing, and tab stops in TextKit and AttributedString. Covers lineBreakMode, lineBreakStrategy, hyphenationFactor, usesDefaultHyphenation, soft hyphens, allowsDefaultTighteningForTruncation, lineHeightMultiple, minimumLineHeight, maximumLineHeight, lineSpacing, paragraphSpacing, firstLineHeadIndent, headIndent, NSTextTab. Use when text wraps at the wrong points, an ellipsis fails to appear, lines look too tight or too loose, paragraphs ignore vertical spacing, or tab columns are misaligned. Use whenever the user mentions truncation, hyphenation, line height, leading, or paragraph spacing — even if they do not name NSParagraphStyle. Do NOT use for text that must wrap around shapes or flow across columns — see txt-exclusion-paths. Do NOT use for measuring how tall the result will be — see txt-measurement.
Look up authoritative Apple-authored documentation for any text-system or Swift API via Sosumi (sosumi.ai URL swap and MCP server) and Xcode 26.3+ xcrun mcpbridge. Use when an Apple Text skill needs grounding against the actual Apple docs, an exact API signature is required, a Swift compiler diagnostic needs the official explanation, or a recently-shipped framework update has to be verified against the source. This is the entry point for documentation grounding — invoke it before reciting any specific API signature from memory.
Catalog every API access and content shape that flips a UITextView or NSTextView from TextKit 2 (NSTextLayoutManager) to TextKit 1 (NSLayoutManager) compatibility mode. Covers explicit layoutManager access, glyph APIs, multi-container layout, NSTextTable / NSTextTableBlock content, the macOS field-editor cascade, framework-internal fallbacks, detection notifications, and recovery. Use when textView.textLayoutManager unexpectedly returns nil, when Writing Tools degrades to panel-only, when scrolling collapses on large documents after a build, or when auditing third-party code or your own extensions for fallback risk before shipping. Trigger on 'why did Writing Tools go panel-only', 'TextKit 2 stopped working', 'scrolling collapses', or any unexplained `textLayoutManager == nil`, even when 'fallback' isn't named. Do NOT use for symptom-driven debugging — see txt-textkit-debug. Do NOT use for the TK1 vs TK2 picker decision — see txt-textkit-choice.
Add find and replace to text editors using UIFindInteraction with UITextSearching, NSTextFinder with NSTextFinderClient, and the highlighting paths that don't pollute the document — temporary attributes on TextKit 1, rendering attributes on TextKit 2, plus the reversed-iteration replace-all pattern. Trigger on 'add a search bar to my editor', 'cmd-F UI', 'replace-all', 'find next', or 'why isn't UIFindInteraction showing up' even without UIFindInteraction named. Use when the user asks for find bars, search highlighting, replace UX, custom find sessions on non-text views, or replace-all crashes on long documents.
Build rich-text editing in SwiftUI using the iOS 26+ TextEditor with AttributedString binding, AttributedTextSelection for selection-aware formatting, AttributedTextFormattingDefinition and AttributedTextValueConstraint for restricting allowed attributes, and FontResolutionContext for resolving semantic fonts. Use when targeting iOS 26 or later, when evaluating whether the native TextEditor replaces a UIViewRepresentable wrapper, when building a formatting toolbar for a SwiftUI editor, when constraining which formatting users can apply, or when migrating from a UITextView-based wrapper. Do NOT use for plain-text TextEditor on older iOS versions, for UIViewRepresentable wrappers around UITextView (txt-wrap-textview), or for Writing Tools integration (txt-writing-tools).
Customize text drag and drop in editors — UITextDraggable and UITextDroppable on UITextView and UITextField, UITextDragDelegate items and previews, UITextDropProposal actions, UITextDragPreviewRenderer for multi-line previews, falling back to UIDragInteraction/UIDropInteraction for custom UITextInput views, and the NSDraggingSource/NSDraggingDestination architecture on macOS. Use when text drag fails on iPhone, non-editable views need to accept drops, custom drag items or previews are needed, or a custom editor needs drag/drop wired up by hand. Trigger on 'drag a selection out of my editor', 'drop an image into my text view', 'reorder by dragging' even without UITextDraggable / UITextDroppable named. Do NOT use for clipboard operations (see txt-pasteboard).
Choose between Swift Regex and NSRegularExpression for text parsing, and bridge match results to NSRange for use with NSAttributedString and TextKit. Covers regex literals, RegexBuilder DSL, runtime-constructed regexes, AnyRegexOutput, Foundation parser captures (date, currency, localizedInteger), NSRegularExpression patterns and options, NSTextCheckingResult, the NSRange(_:in:) bridge, syntax-highlighting patterns, and the performance and deployment-target tradeoffs that decide which engine to use. Use when picking a regex API for new code, migrating existing NSRegularExpression code to Swift Regex, wiring matches into syntax highlighting or attribute application in NSTextStorage, or debugging "the match is in the wrong place" bugs caused by NSRange/String.Index mismatch. Do NOT use for NLTagger, NLTokenizer, NSDataDetector, or general Natural Language utilities — see txt-detectors-tagger. Do NOT use for Markdown parsing or PresentationIntent — see txt-markdown.
Customize selection UI, edit menus, link taps, gestures, and cursor appearance on UITextView and NSTextView — UIEditMenuInteraction, UITextItem actions and tags, link delegate routing, gesture coordination, tintColor and linkTextAttributes. Use when the user is changing how the stock edit menu, selection rects, link tap, long-press menu, or cursor color behaves on a text view they didn't write from scratch. Do NOT use for full UITextInput protocol implementation in custom views — see txt-uitextinput.
Configure spell checking, autocorrect, smart substitutions, and inline prediction on UITextView and NSTextView, drive UITextChecker and NSSpellChecker directly, and avoid the UITextInteraction correction trap that breaks corrections in custom UITextInput views. Use when spell-check underlines are missing or wrong, autocorrect doesn't apply, completions are needed, code editors need spell-check disabled. Trigger on 'red squiggle', 'autocorrect', 'spell-check', 'predictive text', 'why isn't my correction working' even without formal API names. Continue trigger:, or a custom editor is being told it can't ship with system spell-check because the correction tap routes through private API.
Determine which AttributedString attributes survive the SwiftUI/TextKit boundary, what SwiftUI Text actually renders vs silently ignores, and how AttributedString converts to and from NSAttributedString. Covers attribute scopes (FoundationAttributes, SwiftUIAttributes, UIKitAttributes, AppKitAttributes), the SwiftUI.Font vs UIFont mismatch, presentationIntent rendering gaps, scope-aware conversion, and inline image strategies. Use when an attribute set on AttributedString doesn't render in SwiftUI Text, when conversion to UITextView loses styling, when Markdown headings or lists don't appear, or when bridging shared text content between SwiftUI and a wrapped UITextView. Do NOT use for wrapping UITextView mechanics (txt-wrap-textview) or for the iOS 26 SwiftUI TextEditor APIs (txt-swiftui-texteditor).
Configure TextKit 2 viewport-driven layout, NSTextLayoutFragment / NSTextLineFragment geometry, and rendering attributes vs storage attributes. Covers NSTextViewportLayoutController callbacks, layoutFragmentFrame vs renderingSurfaceBounds, line-fragment local coordinates, the extra trailing line fragment, exclusion paths that split a visual line, lineFragmentPadding vs container insets, font substitution via fixAttributes, and visible/overscroll/estimated regions. Use when working with custom layout fragments, debugging clipped diacritics or descenders, computing document coordinates from a line fragment, integrating with a custom scroll view, or when scroll-bar behavior under estimated heights is the visible problem. Do NOT use for symptom-driven debugging (txt-textkit-debug), the invalidation model (txt-layout-invalidation), or the TextKit 2 API surface in general (txt-textkit2).
Implement and debug undo and redo in text editors — NSUndoManager grouping with beginUndoGrouping/endUndoGrouping, automatic typing coalescing on UITextView and NSTextView, disabling registration around programmatic edits, the changeInLength bug that breaks undo on custom NSTextStorage subclasses, registering manual inverses on NSTextContentManager, and avoiding cross-talk with Writing Tools revert. Trigger on 'undo isn't working right', 'too many undo steps for one paste', 'undo lost my work after Writing Tools', 'cmd-z behaves wrong' even without NSUndoManager named. Use when undo collapses too many changesUse when undo collapses too many changes, splits one operation into many groups, applies wrong inverse ranges, or stops working entirely after a paste, replace-all, or document load.
Choose between SwiftUI Text/TextField/TextEditor, UIKit UITextView, and AppKit NSTextView. Capability comparison, tradeoffs, and decision criteria for read-only display vs single-line input vs multi-line editing vs rich attributed editing vs TextKit access. Use when the user asks "which text view should I use," "should I use TextField or TextEditor," "do I need UITextView for this," or describes a feature without naming a view class. Do NOT use for wrapping UITextView in SwiftUI — see txt-wrap-textview. Do NOT use for SwiftUI/TextKit attribute compatibility rules — see txt-swiftui-interop. Do NOT use for the iOS 26 SwiftUI TextEditor rich-text APIs themselves — see txt-swiftui-texteditor.
Wrap UITextView (UIViewRepresentable) and NSTextView (NSViewRepresentable) inside SwiftUI without breaking editing. Covers binding sync, infinite-update-loop guards, cursor preservation across programmatic mutations, focus / first-responder bridging, auto-sizing strategies, environment value propagation, toolbar integration, and the iOS vs macOS scroll-view differences. Use when building or debugging a SwiftUI text-view wrapper, when cursor jumps after typing, when binding updates don't propagate, when @FocusState seems ignored, or when a wrapped editor won't size to its content. Do NOT use for picking which view class (txt-view-picker) or for which AttributedString attributes survive the SwiftUI boundary (txt-swiftui-interop).
--- name: txt-textkit1 description: Reference for TextKit 1 — NSTextStorage, NSLayoutManager, NSTextContainer. Covers the storage / layout manager / container triad, glyph generation and queries, line-fragment geometry, multi-container layout, exclusion paths, temporary attributes, non-contiguous layout, and NSLayoutManager / NSTextStorage delegate hooks. Use when working with code that already uses NSLayoutManager, when an editor was created with UITextView(usingTextLayoutManager: false), when
Reference for TextKit 2 — NSTextLayoutManager, NSTextContentManager, NSTextContentStorage, NSTextLayoutFragment, NSTextLineFragment. Covers the element-based content model, the editing transaction, viewport-driven layout via NSTextViewportLayoutController, rendering attributes vs storage attributes, fragment enumeration options, range types (NSTextRange / NSTextLocation), and delegate hooks for custom paragraphs and custom layout fragments. Use when the editor uses NSTextLayoutManager, when working on TextKit 2 features (Writing Tools inline, viewport layout, custom fragment rendering), or when bridging an attributed-string backing store into the modern stack. Do NOT use for the picker decision between TK1 and TK2 — see txt-textkit-choice. Do NOT use for symptom-driven debugging — see txt-textkit-debug.
Implement UITextInput, UIKeyInput, or NSTextInputClient in custom views — marked text for CJK input, position and range arithmetic, geometry for system UI, inputDelegate notifications, UITextInteraction adoption. Use when building a text-editing view that does not derive from UITextView or NSTextView and the keyboard, autocorrect, selection handles, magnifier, or IME input is wrong or missing. Do NOT use for selection or edit-menu customization on stock UITextView/NSTextView (see txt-selection-menus) or for find/replace UI (see txt-find-replace).
Wire VoiceOver, accessibility traits, UIAccessibilityReadingContent, accessibilityTextualContext, and announcement notifications into custom or wrapped Apple text editors. Use when a UIViewRepresentable wrapper shadows a UITextView's accessibility, a custom text view doesn't appear in the accessibility tree, VoiceOver reads stale text or skips punctuation in a code editor, programmatic edits aren't announced, or rotor gestures don't navigate by character/word/line. Trigger on 'screen reader', 'VoiceOver', 'blind users', 'WCAG', or 'accessibility audit' even when traits and rotor aren't explicitly named. Do NOT use for Dynamic Type font scaling and content-size category — see txt-dynamic-type.
Pick text colors that adapt to dark mode, vibrancy, and accessibility settings across UIKit, AppKit, and SwiftUI — semantic label colors, AppKit's textColor vs labelColor split, dark-mode adaptation rules, wide-color (Display P3), HDR/EDR limits for text. Use when text disappears in dark mode, an attributed string defaults to invisible black, an NSTextView body looks dim, you're picking between systemRed and a P3 red, or designing for high-contrast accessibility. Read the actual color initializers and trait responses before reciting fixes — the patterns here describe how color adaptation usually fails, not where the bug is in your code.
Choose between TextKit 1 (NSLayoutManager) and TextKit 2 (NSTextLayoutManager) and weigh migration risk. Covers feature gates that force one stack (glyph access, multi-container layout, NSTextTable, Writing Tools inline, syntax-highlighting reliability), real-world performance evidence on large documents, scroll-bar behavior under estimated heights, line-counting cost on each stack, and dual-code-path patterns for code that needs to support both. Use when starting a new editor and deciding which stack to commit to, when an existing TextKit 1 codebase is debating migration, or when fallback pressure is forcing the question of whether to stay on TextKit 1 deliberately. Do NOT use for the API reference of either stack — see txt-textkit1 / txt-textkit2.