axiom-textkit-ref

Reference Apple's TextKit 2 architecture and migration from TextKit 1.

Updated Dec 3, 2025
One-click install
npx skills add https://github.com/tuliopc23/flying-dutchman-app --skill axiom-textkit-ref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axiom-textkit-ref
Source: https://github.com/tuliopc23/flying-dutchman-app/tree/main/.claude/skills/axiom-textkit-ref
Command: npx skills add https://github.com/tuliopc23/flying-dutchman-app --skill axiom-textkit-ref

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive reference for Apple's TextKit 2 framework, enabling developers to build sophisticated text-based UIs with improved performance, safety, and correctness.

Core Features & Use Cases

  • Deep Dive into TextKit 2 Architecture: Understand the Model-View-Controller (MVC) pattern and new classes like NSTextLayoutManager and NSTextLayoutFragment.
  • Migration Guidance: Learn how to transition from TextKit 1, including API replacements and compatibility considerations.
  • Advanced Features: Explore Writing Tools integration, SwiftUI TextEditor with AttributedString, and custom layout implementations.
  • Use Case: A developer needs to implement a rich text editor in their iOS app that supports custom styling, inline attachments, and efficient layout for large documents. This Skill provides the necessary architectural overview and code examples.

Quick Start

Refer to the TextKit 2 architecture section to understand the roles of NSTextLayoutManager and NSTextLayoutFragment.

Frequently Asked Questions about axiom-textkit-ref

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

FAQPage Schema
What is TextKit 2 and how does its architecture differ from TextKit 1?

TextKit 2 is Apple's framework for advanced text rendering, utilizing an MVC architecture with object-based ranges and value semantics. It introduces new classes like NSTextLayoutManager and NSTextLayoutFragment to replace the older coordinate-based system found in TextKit 1.

How do I migrate my rich text editor from TextKit 1 to TextKit 2?

Migrating to TextKit 2 involves transitioning your text handling to object-based ranges and adopting NSTextLayoutManager. You must evaluate API replacements, manage compatibility considerations, and adapt your layout logic to leverage the new viewport-based rendering system for enhanced performance.

Can I use TextKit 2 with SwiftUI TextEditor and AttributedString?

Yes, TextKit 2 integrates with SwiftUI TextEditor using AttributedString. This combination enables you to build sophisticated text-based UIs in iOS and macOS applications while supporting custom styling and inline attachments with improved safety and correctness.

Does TextKit 2 improve text rendering performance for large documents?

Yes, TextKit 2 improves text rendering performance for large documents through viewport layout and NSTextLayoutFragment. By calculating layout only for the visible viewport using object-based ranges, it avoids processing the entire document, ensuring efficient rendering.

What are the limitations of using TextKit 2 for iOS and macOS development?

TextKit 2 limitations include compatibility considerations when migrating legacy TextKit 1 code, requiring adaptation to value semantics and object-based ranges. Complex custom layouts necessitate deep understanding of NSTextLayoutManager and NSTextLayoutFragment, potentially increasing initial development complexity.

When do I need NSTextLayoutFragment for custom text layouts in iOS?

You need NSTextLayoutFragment when implementing custom text layouts in iOS or macOS applications. It represents discrete portions of text layout generated by NSTextLayoutManager, allowing you to manipulate viewport rendering and achieve advanced visual styling for rich text editors.