pencilkit

Capture Apple Pencil and finger input into serializable PKDrawing data.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/KumarAdi8/AgentKit --skill pencilkit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pencilkit
Source: https://github.com/KumarAdi8/AgentKit/tree/main/skills/pencilkit
Command: npx skills add https://github.com/KumarAdi8/AgentKit --skill pencilkit

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Capture native Apple Pencil and touch input, manage drawing tools, and persist ink so apps can offer reliable drawing, annotation, signature capture, and exportable artwork without reinventing the input pipeline.

Core Features & Use Cases

  • Canvas input capture: Configure and manage a PKCanvasView to accept pencil and finger strokes with appropriate drawingPolicy and tool assignments.
  • Tool management and UX: Present and observe a PKToolPicker to let users choose inks, erasers, lasso, and ruler tools while keeping the picker lifecycle correct.
  • Persistence and export: Serialize PKDrawing to Data, combine and transform drawings, export regions as images, and manage content version compatibility for cross-version sharing.
  • SwiftUI integration: Provide a UIViewRepresentable wrapper pattern to bind PKDrawing into SwiftUI and avoid update loops.
  • Use Case: Add an annotation editor to a document app that lets users draw with Apple Pencil, switch tools, save drawings to disk, and generate thumbnails for a gallery.

Quick Start

Embed a canvas view or SwiftUI wrapper bound to a PKDrawing state, show the tool picker for the canvas, capture edits, and save the drawing.dataRepresentation() to a file when the user finishes.

Frequently Asked Questions about pencilkit

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

FAQPage Schema
How do I capture Apple Pencil input into a serializable data format in SwiftUI?

Capture Apple Pencil input into a serializable PKDrawing data representation by configuring a PKCanvasView with appropriate drawingPolicy. Use a UIViewRepresentable wrapper to bind PKDrawing state into SwiftUI, capturing pencil and finger strokes while avoiding update loops.

How do I save and export PKDrawing data from an iOS canvas view?

Save and export PKDrawing data by serializing the drawing object using dataRepresentation() to persist it to disk. You can also combine and transform drawings, export specific canvas regions as images, and manage content version compatibility for cross-version sharing.

Does PencilKit work with SwiftUI on iPadOS and visionOS?

PencilKit works with SwiftUI on iPadOS and visionOS by using a UIViewRepresentable wrapper pattern to integrate PKCanvasView. This wrapper binds PKDrawing into SwiftUI state, compatible with Swift 6.3 and iOS 26+, enabling native drawing and annotation features.

How do I manage the PKToolPicker lifecycle when presenting drawing tools?

Manage the PKToolPicker lifecycle by presenting and observing the picker to let users choose inks, erasers, lasso, and ruler tools. Ensure the picker visibility stays correctly synchronized with your PKCanvasView to maintain a stable drawing interface.

Can I use PKCanvasView for finger input alongside Apple Pencil strokes?

PKCanvasView accepts finger input alongside Apple Pencil strokes by configuring the appropriate drawingPolicy. This allows the canvas to capture both touch and pencil inputs simultaneously for flexible drawing, annotation, and signature capture scenarios.

What is the best way to inspect strokes within a PKDrawing object?

Inspect strokes within a PKDrawing object by accessing the individual stroke elements after capturing input into the serializable data representation. This stroke inspection allows you to analyze and transform ink data before exporting regions as images or saving to disk.