PaperKit
Combine freeform PencilKit drawings with structured markup elements (shapes, text boxes, images, connectors) using PaperKit (PaperMarkupViewController, PaperMarkup). Targets Swift 6.3 / iOS 26+.
Beta-sensitive: PaperKit is new in iOS/iPadOS 26, macOS 26, and visionOS 26. Verify availability guards and SDK versions before production release.
Contents
PaperKit Architecture
PaperKit provides an interactive document canvas hosting both vector PencilKit strokes and structured document annotations.
┌────────────────────────────────────────────────────────┐
│ PaperMarkupViewController │
│ ┌───────────────────────┐ ┌────────────────────────┐ │
│ │ PKToolPicker │ │ MarkupEditController │ │
│ │ (PencilKit Inking) │ │ (Shapes, Text, Images) │ │
│ └───────────────────────┘ └────────────────────────┘ │
│ │
│ Canvas: PaperMarkup (Strokes + Shapes + Text Objects) │
└────────────────────────────────────────────────────────┘
PencilKit vs PaperKit Boundary
pencilkit: Use for pure freehand sketchbooks, drawing-only canvases, raw vector stroke analysis, or when supporting iOS 17 and earlier.
paperkit: Use when users need to place shapes, typed text, sticky notes, or signature annotations alongside freehand drawings in document editors.
Core Components
| Component |
Role |
PaperMarkupViewController |
Scrollable interactive markup canvas hosting drawings and elements |
PaperMarkup |
Serializable document model representing canvas elements and bounds |
MarkupEditViewController |
System UI for inserting shapes, text, arrows, and signatures |
MarkupToolbarViewController |
Toolbar controller coordinating tools on desktop and iPad |
FeatureSet |
Capability configuration declaring supported tools and element types |
Persistence and Feature Sets
- Serialization: Save and restore
PaperMarkup using markup.dataRepresentation().
- FeatureSet Compatibility: Initialize view controllers with explicit feature sets (e.g.
FeatureSet.latest or targeted subsets) to prevent forward-compatibility loading errors.
- Thumbnail Rendering: Generate raster thumbnail previews off the main thread for fast document list loading.
Route by Task
- For full UIKit setup, delegate lifecycle, and embedding in parent controllers, read PaperMarkupViewController Setup.
- For SwiftUI integration with
UIViewControllerRepresentable, read SwiftUI PaperKit Integration.
- For custom tool picker coordination and first-responder management, read Tool Picker Coordination.
- For document serialization, thumbnail generation, and backward compatibility, read Persistence and Thumbnails.
Common Mistakes
- Presenting markup insertion controllers without anchoring to a valid bar button or source rect.
- Recreating
PaperMarkupViewController on every SwiftUI view update rather than using coordinator pattern.
- Performing
PaperMarkup serialization synchronously on the main thread for large multi-element documents.
- Omitting availability checks (
@available(iOS 26.0, *)) when deploying to earlier OS versions.
- Failing to synchronize document bounds between
PaperMarkup and the hosting view layout.
Review Checklist
References
1---2name: paperkit3description: Add drawings, shapes, and a consistent markup experience using PaperKit. Use when integrating PaperMarkupViewController for markup editing, adding shape recognition, working with PaperMarkup data models, embedding markup tools in document editors, or building annotation features that need the system-standard markup toolbar. New in iOS 26.4---56# PaperKit78Combine freeform PencilKit drawings with structured markup elements (shapes, text boxes, images, connectors) using `PaperKit` (`PaperMarkupViewController`, `PaperMarkup`). Targets Swift 6.3 / iOS 26+.910> **Beta-sensitive:** PaperKit is new in iOS/iPadOS 26, macOS 26, and visionOS 26. Verify availability guards and SDK versions before production release.1112## Contents1314- [PaperKit Architecture](#paperkit-architecture)15- [PencilKit vs PaperKit Boundary](#pencilkit-vs-paperkit-boundary)16- [Core Components](#core-components)17- [Persistence and Feature Sets](#persistence-and-feature-sets)18- [Route by Task](#route-by-task)19- [Common Mistakes](#common-mistakes)20- [Review Checklist](#review-checklist)21- [References](#references)2223## PaperKit Architecture2425PaperKit provides an interactive document canvas hosting both vector PencilKit strokes and structured document annotations.2627```28┌────────────────────────────────────────────────────────┐29│ PaperMarkupViewController │30│ ┌───────────────────────┐ ┌────────────────────────┐ │31│ │ PKToolPicker │ │ MarkupEditController │ │32│ │ (PencilKit Inking) │ │ (Shapes, Text, Images) │ │33│ └───────────────────────┘ └────────────────────────┘ │34│ │35│ Canvas: PaperMarkup (Strokes + Shapes + Text Objects) │36└────────────────────────────────────────────────────────┘37```3839## PencilKit vs PaperKit Boundary4041- **`pencilkit`**: Use for pure freehand sketchbooks, drawing-only canvases, raw vector stroke analysis, or when supporting iOS 17 and earlier.42- **`paperkit`**: Use when users need to place shapes, typed text, sticky notes, or signature annotations alongside freehand drawings in document editors.4344## Core Components4546| Component | Role |47|---|---|48| `PaperMarkupViewController` | Scrollable interactive markup canvas hosting drawings and elements |49| `PaperMarkup` | Serializable document model representing canvas elements and bounds |50| `MarkupEditViewController` | System UI for inserting shapes, text, arrows, and signatures |51| `MarkupToolbarViewController` | Toolbar controller coordinating tools on desktop and iPad |52| `FeatureSet` | Capability configuration declaring supported tools and element types |5354## Persistence and Feature Sets55561. **Serialization**: Save and restore `PaperMarkup` using `markup.dataRepresentation()`.572. **FeatureSet Compatibility**: Initialize view controllers with explicit feature sets (e.g. `FeatureSet.latest` or targeted subsets) to prevent forward-compatibility loading errors.583. **Thumbnail Rendering**: Generate raster thumbnail previews off the main thread for fast document list loading.5960## Route by Task6162- For full UIKit setup, delegate lifecycle, and embedding in parent controllers, read [PaperMarkupViewController Setup](references/paperkit-patterns.md#papermarkupviewcontroller-setup).63- For SwiftUI integration with `UIViewControllerRepresentable`, read [SwiftUI PaperKit Integration](references/paperkit-patterns.md#swiftui-integration).64- For custom tool picker coordination and first-responder management, read [Tool Picker Coordination](references/paperkit-patterns.md#tool-picker-coordination).65- For document serialization, thumbnail generation, and backward compatibility, read [Persistence and Thumbnails](references/paperkit-patterns.md#persistence-and-thumbnails).6667## Common Mistakes6869- Presenting markup insertion controllers without anchoring to a valid bar button or source rect.70- Recreating `PaperMarkupViewController` on every SwiftUI view update rather than using coordinator pattern.71- Performing `PaperMarkup` serialization synchronously on the main thread for large multi-element documents.72- Omitting availability checks (`@available(iOS 26.0, *)`) when deploying to earlier OS versions.73- Failing to synchronize document bounds between `PaperMarkup` and the hosting view layout.7475## Review Checklist7677- [ ] `PaperMarkupViewController` hosted in a stable UIKit container or SwiftUI Coordinator78- [ ] Availability guarded for iOS 26+79- [ ] Insertion controllers properly anchored to source views or bar button items80- [ ] `PKToolPicker` added as observer to the paper markup controller81- [ ] Document serialization performed asynchronously in background tasks82- [ ] Undo and redo actions integrated with the canvas `UndoManager`8384## References8586- [PaperKit extended recipes and SwiftUI wrappers](references/paperkit-patterns.md)87- [PaperKit documentation](https://sosumi.ai/documentation/paperkit)88- [PencilKit documentation](https://sosumi.ai/documentation/pencilkit)