What problem does it solve? TextKit 2 replaces TextKit 1 with an element-based, viewport-driven model that breaks many assumptions from NSLayoutManager-era code, and its API surface keeps changing across iOS releases. This Skill provides a verified reference for the modern stack so you avoid stale fragments, clipped drawing, and full-document layout traps. ## Core Features & Use Cases - API Reference: Covers NSTextContentManager, NSTextContentStorage, NSTextLayoutManager, NSTextLayoutFragment, NSTextLineFragment, NSTextViewportLayoutController, and object-based NSTextRange/NSTextLocation addressing. - Common Mistakes Catalog: Documents ten confirmed pitfalls, including editing outside performEditingTransaction, treating line-fragment characterRange as document-relative, and calling ensureLayout over the document range. - Migration Mapping: A sidecar reference maps TextKit 1 APIs (glyph APIs, temporary attributes, boundingRect) to their TextKit 2 equivalents or flags cases with no equivalent. - Use Case: When adding Writing Tools inline support or a custom code-block background to an NSTextLayoutManager-based editor, consult this Skill to wire the viewport delegate callbacks and supply a custom NSTextLayoutFragment subclass correctly. ## Quick Start Ask how to correctly invalidate layout and redraw a paragraph range in an NSTextLayoutManager-based text view.