
Pencilkit
Implement iPad-first drawing screens in SwiftUI with Apple Pencil, tool picker lifecycle, and reliable PKDrawing save/load.
Install
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill pencilkitWhat is this skill?
- Wraps PKCanvasView with UIViewRepresentable and a Coordinator implementing PKCanvasViewDelegate
- Documents PKToolPicker retention, observer wiring, and first-responder ordering to avoid stale tools
- Compares .default, .anyInput, and .pencilOnly drawing policies for Pencil-primary vs finger drawing
- Persists drawings via PKDrawing.dataRepresentation() and reloads with PKDrawing(data:)
- Guards against SwiftUI update loops by syncing binding only when canvas drawing differs
Adoption & trust: 1.2k installs on skills.sh; 713 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Vercel React Native Skillsvercel-labs/agent-skills
Firebase Basicsfirebase/agent-skills
Building Native Uiexpo/skills
Firebase Ai Logic Basicsfirebase/agent-skills
Native Data Fetchingexpo/skills
Firebase Firestorefirebase/agent-skills
Journey fit
Primary fit
PencilKit UI integration is core product construction for iOS/iPad apps, so the canonical shelf is Build → frontend. The skill covers UIViewRepresentable wrappers, canvas delegates, and drawing policies—mobile UI implementation, not backend or App Store launch ops.
Common Questions / FAQ
Is Pencilkit safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Pencilkit
{ "skill_name": "pencilkit", "evals": [ { "id": 0, "prompt": "I'm building a SwiftUI drawing screen for iPad with Apple Pencil and optional finger drawing. Sketch the PencilKit wrapper, tool picker setup, save/load path, and the lifecycle details that prevent stale tools or update loops.", "expected_output": "A SwiftUI PencilKit implementation plan that wraps PKCanvasView, retains and observes PKToolPicker, chooses an appropriate drawingPolicy, serializes PKDrawing with dataRepresentation()/PKDrawing(data:), and avoids binding update loops.", "files": [], "expectations": [ "Wraps PKCanvasView with UIViewRepresentable and uses a Coordinator as PKCanvasViewDelegate.", "Retains PKToolPicker outside a local scope and adds the canvas as an observer before showing the picker or becoming first responder.", "Explains the difference between .default, .anyInput, and .pencilOnly enough to choose one for Pencil-primary versus finger-drawing modes.", "Persists drawings using PKDrawing.dataRepresentation() and reloads with PKDrawing(data:).", "Avoids SwiftUI update loops by checking whether the canvas drawing already matches the binding before assigning." ] }, { "id": 1, "prompt": "Review this PencilKit compatibility plan: let users pick watercolor, crayon, and reed, save the PKDrawing bytes to CloudKit, and set canvasView.maximumSupportedContentVersion = .version2 so iPadOS 16 clients can open every drawing. What should change?", "expected_output": "A correction-focused review that explains PencilKit content versions, unsupported-ink load failures, the need to set maximumSupportedContentVersion on both canvas and tool picker, and the version boundary for iPadOS 17 and iOS 26 inks.", "files": [], "expectations": [ "States that unsupported newer inks cause older systems to fail when loading PKDrawing data rather than guaranteeing compatibility.", "Correctly maps version1 to marker/pen/pencil-era compatibility, version2 to iPadOS 17 inks, version3 to barrel-roll angle data, and version4 to reed.", "Explains that .version2 does not make drawings loadable by iPadOS 16 clients; use .version1 or a fallback for pre-iPadOS 17 compatibility.", "Sets maximumSupportedContentVersion on both PKCanvasView and PKToolPicker when restricting new content.", "Calls out .reed as iOS/iPadOS/macOS/visionOS 26+ and custom tool picker items as iOS/iPadOS 18+ or visionOS 2+." ] }, { "id": 2, "prompt": "I need an annotation experience with freehand Apple Pencil signatures, movable text boxes, arrows, image stickers, and a standard markup toolbar. Which parts should stay in PencilKit and when should I switch to PaperKit?", "expected_output": "A boundary-aware answer that keeps freeform drawing, tool picker, stroke inspection, image export, and PKDrawing serialization in PencilKit while routing structured markup and toolbar needs to PaperKit.", "files": [], "expectations": [ "Keeps PencilKit scope to PKCanvasView, PKToolPicker, PKDrawing serialization/export, stroke inspection, and signature/freehand drawing.", "Routes shapes, arrows, text boxes, images/stickers, loupes, and system-standard markup toolbar work to PaperKit.", "Mentions the verified bridge points: PaperMarkupViewController.drawingTool accepts a PKTool and PaperMarkup can append PKDrawing.", "Does not claim PencilKit directly owns structured markup elements such as movable text boxes or stickers.", "Preserves a practical handoff plan between saved PKDrawing content and a PaperKit markup workflow." ] } ] } # PencilKit Extended Patterns Overflow reference for the `pencilkit` skill. Contains advanced patterns that exceed the main skill file's scope. ## Contents - [Tool Picker Observer Pattern](#tool-picker-observer-pattern) - [Custom Tool Picker Ite