textkit-ref

Document TextKit 2 architecture, migration, and iOS integration details.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill textkit-ref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: textkit-ref
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/.claude-plugin/plugins/axiom/skills/textkit-ref
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill textkit-ref

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Complete reference for TextKit 2 covering architecture, migration, Writing Tools, and SwiftUI TextEditor with AttributedString through iOS 26.

Core Features & Use Cases

  • Architecture overview and major components (NSTextContentStorage, NSTextLayoutManager, NSTextElement, etc.)
  • Controller/View patterns and viewport layout
  • Migration guidance from TextKit 1 to 2 and API naming heuristics
  • NSTextRange/NSTextLocation usage

Quick Start

Explain how to migrate a TextKit 1 NSRange-based implementation to TextKit 2 using NSTextLocation and NSTextRange.

Frequently Asked Questions about textkit-ref

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from TextKit 1 to TextKit 2 in iOS?

TextKit 2 replaces NSRange-based APIs with NSTextLocation and NSTextRange for immutable element semantics and noncontiguous viewport layout. Migration involves updating content storage to NSTextContentStorage, replacing NSLayoutManager with NSTextLayoutManager, and refactoring controller patterns to work with the new MVC model and high-level primitives.

What is TextKit 2 and how does it work?

TextKit 2 is Apple's modern text rendering framework for iOS that separates content storage, layout, and viewport management into distinct components. It provides NSTextElement, NSTextContentStorage, and NSTextLayoutManager to handle architecture, immutable semantics, and high-level text location and range operations without legacy glyph APIs.

Can I use TextKit 2 with SwiftUI TextEditor and Writing Tools?

Yes, TextKit 2 integrates with SwiftUI TextEditor through AttributedString and supports Writing Tools on iOS 26. The framework's modern architecture and high-level primitives enable seamless integration with SwiftUI's text editing components and system-level writing assistants.

How do NSTextLocation and NSTextRange work in TextKit 2?

NSTextLocation and NSTextRange are high-level primitives in TextKit 2 that replace NSRange for text selection and positioning. They support noncontiguous ranges and immutable semantics, enabling precise navigation and content manipulation within the new architecture's content storage and layout system.

What are the key architectural components of TextKit 2?

TextKit 2 core components include NSTextContentStorage for content representation, NSTextLayoutManager for layout calculations, NSTextElement for content granularity, and NSTextSelection for viewport and selection management. These work together in an MVC pattern to separate concerns across content, layout, and view layers.