UIKit & Bridging
You MUST use this skill for ANY UIKit bridging, Auto Layout, Combine, TextKit, or UIKit animation work.
Auditors are skills here. Where this router says "Launch some-auditor agent", invoke the
matching Codex skill instead — same procedure, no Claude Code agent required.
Available: axiom-audit-resize.
The ones that shell out — builds, tests, simulators, crash symbolication — need shell access to run.
Quick Reference
| Symptom / Task |
Reference |
| UIViewRepresentable, UIViewControllerRepresentable |
See skills/uikit-bridging.md |
| Embedding SwiftUI in UIKit (UIHostingController) |
See skills/uikit-bridging.md |
| Coordinator pattern, updateUIView lifecycle |
See skills/uikit-bridging.md |
| Building adaptive UIKit layout: guides, width-conditional constraints, compositional layout, self-sizing cells |
See skills/adaptive-layout.md |
| "Unable to simultaneously satisfy constraints" |
See skills/auto-layout-debugging.md |
| Constraint conflicts, ambiguous layout |
See skills/auto-layout-debugging.md |
| Views not appearing, positioned incorrectly |
See skills/auto-layout-debugging.md |
| CAAnimation completion handler not firing |
See skills/uikit-animation-debugging.md |
| Spring physics wrong on device, duration mismatch |
See skills/uikit-animation-debugging.md |
| Animation jank, CATransaction timing |
See skills/uikit-animation-debugging.md |
| Combine publishers, AnyCancellable lifecycle |
See skills/combine-patterns.md |
| @Published properties, Combine ↔ async/await |
See skills/combine-patterns.md |
| When to use Combine vs async/await |
See skills/combine-patterns.md |
UIScene lifecycle required, resizable apps, size classes, tab sidebar OS27 |
See skills/uikit-modernization.md |
| iPhone Mirroring compat: indirect input, companion Face ID, portrait trap |
See skills/uikit-modernization.md |
| Scene edges: teardown, activation requests, per-scene restoration, external display, activeAppearance |
See skills/uikit-modernization.md |
| Automated resize-readiness scan (scene lifecycle, UIScreen.main, fixed-canvas, Mirroring input) |
axiom-audit-resize |
| TextKit 2 architecture, NSTextLayoutManager |
See skills/textkit-ref.md |
| Writing Tools integration (iOS 26) |
See skills/textkit-ref.md |
Viewport rendering surfaces, attachment reuse, collapsible text OS27 |
See skills/textkit-ref.md |
| SwiftUI TextEditor, TextKit 1 migration |
See skills/textkit-ref.md |
| PencilKit canvas, PKToolPicker, drawing persistence |
See skills/pencilkit-paperkit.md |
| Apple Pencil Pro (squeeze, barrel roll, hover, haptics) |
See skills/pencilkit-paperkit.md |
Handwriting recognition (PKStrokeRecognizer), stroke identity/slicing OS27 |
See skills/pencilkit-paperkit-ref.md |
| PaperKit markup canvas (shapes, images, text + drawing) |
See skills/pencilkit-paperkit-ref.md |
PaperKit programmatic markup model (subelements, adornments) OS27 |
See skills/pencilkit-paperkit-ref.md |
Decision Tree
digraph uikit {
start [label="UIKit task" shape=ellipse];
what [label="What do you need?" shape=diamond];
start -> what;
what -> "skills/uikit-bridging.md" [label="wrap UIKit in SwiftUI\nor SwiftUI in UIKit"];
what -> "skills/adaptive-layout.md" [label="build adaptive layout\n(guides, constraint sets,\ncompositional)"];
what -> "skills/auto-layout-debugging.md" [label="constraint errors,\nlayout issues"];
what -> "skills/uikit-animation-debugging.md" [label="CAAnimation bugs,\nspring physics,\ncompletion handlers"];
what -> "skills/combine-patterns.md" [label="publishers, sinks,\n@Published,\nasync/await bridge"];
what -> "skills/textkit-ref.md" [label="text layout,\nWriting Tools,\nTextKit migration"];
what -> "skills/pencilkit-paperkit.md" [label="drawing canvas,\nApple Pencil,\nPaperKit markup"];
what -> "skills/uikit-modernization.md" [label="scene lifecycle (required 27),\nresizable apps,\nsize classes"];
}
- Scene-lifecycle migration, "app won't launch on 27", resizability, size classes, tab sidebar? →
skills/uikit-modernization.md
0b. App misbehaves in iPhone Mirroring (gestures dead, Face ID blocked, layout stuck portrait)? → skills/uikit-modernization.md
- UIViewRepresentable / UIViewControllerRepresentable / UIHostingController? →
skills/uikit-bridging.md
- "Unable to simultaneously satisfy constraints" / layout bugs? →
skills/auto-layout-debugging.md
2b. Building a layout that adapts (layout guides, size-class constraint sets, compositional column math, self-sizing cells)? → skills/adaptive-layout.md
- CAAnimation completion missing / spring physics wrong / animation jank? →
skills/uikit-animation-debugging.md
- Combine publishers / AnyCancellable / @Published / Combine ↔ async bridge? →
skills/combine-patterns.md
- TextKit 2 / Writing Tools / TextEditor / TextKit 1 migration? →
skills/textkit-ref.md
- PencilKit canvas / Apple Pencil / PaperKit markup? →
skills/pencilkit-paperkit.md
- Pure SwiftUI view question (no UIKit bridging)? →
/skill axiom-swiftui
- Design decisions, HIG, Liquid Glass, SF Symbols, typography? →
/skill axiom-design
- Block retain cycles in UIKit callbacks? → See axiom-performance (
skills/objc-block-retain-cycles.md)
- Memory leaks from Combine subscriptions? → Start with
skills/combine-patterns.md, then axiom-performance if leak persists
Conflict Resolution
uikit vs swiftui: When working with UI code:
- Use uikit when wrapping UIKit in SwiftUI or vice versa, or debugging UIKit-specific issues (Auto Layout, CAAnimation)
- Use swiftui for pure SwiftUI views, navigation, layout, animations
uikit vs concurrency: When Combine interacts with async/await:
- Use uikit (
skills/combine-patterns.md) for bridging Combine pipelines with async/await
- Use concurrency for pure async/await patterns, actors, Sendable
uikit vs performance: When animations or layout cause performance issues:
- Try uikit FIRST — Most animation jank is CATransaction timing or layer state, not a profiling issue
- Only use performance if animation logic is correct but rendering is slow
uikit vs axiom-data: When @Published properties relate to data persistence:
- Use uikit for Combine publisher patterns and @Published lifecycle
- Use axiom-data for SwiftData/Core Data model layer concerns
Anti-Rationalization
| Thought |
Reality |
| "I'll just use UIHostingController, it's simple" |
Hosting has sizing, lifecycle, and navigation edge cases. skills/uikit-bridging.md covers the gotchas. |
| "Auto Layout error is just a warning, I'll ignore it" |
Unsatisfied constraints cause unpredictable layout at runtime. Fix them now. |
| "I know how CAAnimation works" |
90% of CAAnimation bugs are CATransaction timing, not Core Animation. Check skills/uikit-animation-debugging.md. |
| "Combine is dead, just rewrite with async/await" |
Combine has no deprecation notice. Rewriting working pipelines wastes time. skills/combine-patterns.md covers when to migrate vs maintain. |
| "TextKit 1 still works fine" |
TextKit 1 misses Writing Tools integration and has known layout bugs Apple won't fix. See skills/textkit-ref.md. |
| "I'll store cancellables in a local variable" |
Local AnyCancellable deallocates immediately, killing the subscription. |
| "I'll archive the PKCanvasView to save the drawing" |
Archiving the view loses editability. Persist drawing.dataRepresentation(). See skills/pencilkit-paperkit.md. |
| "My tool picker won't show, the API must be broken" |
The canvas must becomeFirstResponder() after setVisible(_:forFirstResponder:). See skills/pencilkit-paperkit.md. |
Example Invocations
User: "How do I wrap a UIKit view in SwiftUI?"
→ Read: skills/uikit-bridging.md
User: "I'm getting 'Unable to simultaneously satisfy constraints'"
→ Read: skills/auto-layout-debugging.md
User: "My CAAnimation completion handler never fires"
→ Read: skills/uikit-animation-debugging.md
User: "Should I use Combine or async/await for this?"
→ Read: skills/combine-patterns.md
User: "How do I integrate Writing Tools with my text editor?"
→ Read: skills/textkit-ref.md
User: "How do I add an Apple Pencil drawing canvas with the tool picker?"
→ Read: skills/pencilkit-paperkit.md
User: "How do I add a PaperKit markup canvas with shapes and text?"
→ Read: skills/pencilkit-paperkit-ref.md
User: "My SwiftUI view has a memory leak from a Combine subscription"
→ Read: skills/combine-patterns.md
User: "How do I embed SwiftUI in my UIKit app?"
→ Read: skills/uikit-bridging.md
User: "Audit my app for screen resizing support"
→ axiom-audit-resize (or axiom-audit-resize)
User: "My custom pinch gesture stops working when the app runs in iPhone Mirroring"
→ Read: skills/uikit-modernization.md
User: "How do I vary my collection view's column count with the window width?"
→ Read: skills/adaptive-layout.md
1---2name: axiom-uikit3description: Use when bridging UIKit and SwiftUI, modernizing UIKit apps (scene lifecycle, resizability), debugging Auto Layout, Combine, TextKit, PencilKit, or UIKit animations.4license: MIT5---6
7# UIKit & Bridging
8
9**You MUST use this skill for ANY UIKit bridging, Auto Layout, Combine, TextKit, or UIKit animation work.**
10
11<!-- AXIOM_AUDITOR_INLINE_BEGIN — rewritten for Codex by scripts/build-codex.ts; do not hand-edit -->
12> **Auditors are skills here.** Where this router says "Launch `some-auditor` agent", invoke the
13> matching Codex skill instead — same procedure, no Claude Code agent required.
14>
15> Available: `axiom-audit-resize`.
16>
17> The ones that shell out — builds, tests, simulators, crash symbolication — need shell access to run.
18<!-- AXIOM_AUDITOR_INLINE_END -->
19
20## Quick Reference
21
22| Symptom / Task | Reference |
23|----------------|-----------|
24| UIViewRepresentable, UIViewControllerRepresentable | See `skills/uikit-bridging.md` |
25| Embedding SwiftUI in UIKit (UIHostingController) | See `skills/uikit-bridging.md` |
26| Coordinator pattern, updateUIView lifecycle | See `skills/uikit-bridging.md` |
27| Building adaptive UIKit layout: guides, width-conditional constraints, compositional layout, self-sizing cells | See `skills/adaptive-layout.md` |
28| "Unable to simultaneously satisfy constraints" | See `skills/auto-layout-debugging.md` |
29| Constraint conflicts, ambiguous layout | See `skills/auto-layout-debugging.md` |
30| Views not appearing, positioned incorrectly | See `skills/auto-layout-debugging.md` |
31| CAAnimation completion handler not firing | See `skills/uikit-animation-debugging.md` |
32| Spring physics wrong on device, duration mismatch | See `skills/uikit-animation-debugging.md` |
33| Animation jank, CATransaction timing | See `skills/uikit-animation-debugging.md` |
34| Combine publishers, AnyCancellable lifecycle | See `skills/combine-patterns.md` |
35| @Published properties, Combine ↔ async/await | See `skills/combine-patterns.md` |
36| When to use Combine vs async/await | See `skills/combine-patterns.md` |
37| UIScene lifecycle required, resizable apps, size classes, tab sidebar `OS27` | See `skills/uikit-modernization.md` |
38| iPhone Mirroring compat: indirect input, companion Face ID, portrait trap | See `skills/uikit-modernization.md` |
39| Scene edges: teardown, activation requests, per-scene restoration, external display, activeAppearance | See `skills/uikit-modernization.md` |
40| Automated resize-readiness scan (scene lifecycle, UIScreen.main, fixed-canvas, Mirroring input) | `axiom-audit-resize` |
41| TextKit 2 architecture, NSTextLayoutManager | See `skills/textkit-ref.md` |
42| Writing Tools integration (iOS 26) | See `skills/textkit-ref.md` |
43| Viewport rendering surfaces, attachment reuse, collapsible text `OS27` | See `skills/textkit-ref.md` |
44| SwiftUI TextEditor, TextKit 1 migration | See `skills/textkit-ref.md` |
45| PencilKit canvas, PKToolPicker, drawing persistence | See `skills/pencilkit-paperkit.md` |
46| Apple Pencil Pro (squeeze, barrel roll, hover, haptics) | See `skills/pencilkit-paperkit.md` |
47| Handwriting recognition (PKStrokeRecognizer), stroke identity/slicing `OS27` | See `skills/pencilkit-paperkit-ref.md` |
48| PaperKit markup canvas (shapes, images, text + drawing) | See `skills/pencilkit-paperkit-ref.md` |
49| PaperKit programmatic markup model (subelements, adornments) `OS27` | See `skills/pencilkit-paperkit-ref.md` |
50
51## Decision Tree
52
53```dot
54digraph uikit {
55 start [label="UIKit task" shape=ellipse];
56 what [label="What do you need?" shape=diamond];
57
58 start -> what;
59 what -> "skills/uikit-bridging.md" [label="wrap UIKit in SwiftUI\nor SwiftUI in UIKit"];
60 what -> "skills/adaptive-layout.md" [label="build adaptive layout\n(guides, constraint sets,\ncompositional)"];
61 what -> "skills/auto-layout-debugging.md" [label="constraint errors,\nlayout issues"];
62 what -> "skills/uikit-animation-debugging.md" [label="CAAnimation bugs,\nspring physics,\ncompletion handlers"];
63 what -> "skills/combine-patterns.md" [label="publishers, sinks,\n@Published,\nasync/await bridge"];
64 what -> "skills/textkit-ref.md" [label="text layout,\nWriting Tools,\nTextKit migration"];
65 what -> "skills/pencilkit-paperkit.md" [label="drawing canvas,\nApple Pencil,\nPaperKit markup"];
66 what -> "skills/uikit-modernization.md" [label="scene lifecycle (required 27),\nresizable apps,\nsize classes"];
67}
68```
69
700. Scene-lifecycle migration, "app won't launch on 27", resizability, size classes, tab sidebar? → `skills/uikit-modernization.md`
710b. App misbehaves in iPhone Mirroring (gestures dead, Face ID blocked, layout stuck portrait)? → `skills/uikit-modernization.md`
721. UIViewRepresentable / UIViewControllerRepresentable / UIHostingController? → `skills/uikit-bridging.md`
732. "Unable to simultaneously satisfy constraints" / layout bugs? → `skills/auto-layout-debugging.md`
742b. Building a layout that adapts (layout guides, size-class constraint sets, compositional column math, self-sizing cells)? → `skills/adaptive-layout.md`
753. CAAnimation completion missing / spring physics wrong / animation jank? → `skills/uikit-animation-debugging.md`
764. Combine publishers / AnyCancellable / @Published / Combine ↔ async bridge? → `skills/combine-patterns.md`
775. TextKit 2 / Writing Tools / TextEditor / TextKit 1 migration? → `skills/textkit-ref.md`
786. PencilKit canvas / Apple Pencil / PaperKit markup? → `skills/pencilkit-paperkit.md`
797. Pure SwiftUI view question (no UIKit bridging)? → `/skill axiom-swiftui`
808. Design decisions, HIG, Liquid Glass, SF Symbols, typography? → `/skill axiom-design`
819. Block retain cycles in UIKit callbacks? → See axiom-performance (`skills/objc-block-retain-cycles.md`)
8210. Memory leaks from Combine subscriptions? → Start with `skills/combine-patterns.md`, then axiom-performance if leak persists
83
84## Conflict Resolution
85
86**uikit vs swiftui**: When working with UI code:
87- **Use uikit** when wrapping UIKit in SwiftUI or vice versa, or debugging UIKit-specific issues (Auto Layout, CAAnimation)
88- **Use swiftui** for pure SwiftUI views, navigation, layout, animations
89
90**uikit vs concurrency**: When Combine interacts with async/await:
91- **Use uikit** (`skills/combine-patterns.md`) for bridging Combine pipelines with async/await
92- **Use concurrency** for pure async/await patterns, actors, Sendable
93
94**uikit vs performance**: When animations or layout cause performance issues:
951. **Try uikit FIRST** — Most animation jank is CATransaction timing or layer state, not a profiling issue
962. **Only use performance** if animation logic is correct but rendering is slow
97
98**uikit vs axiom-data**: When @Published properties relate to data persistence:
99- **Use uikit** for Combine publisher patterns and @Published lifecycle
100- **Use axiom-data** for SwiftData/Core Data model layer concerns
101
102## Anti-Rationalization
103
104| Thought | Reality |
105|---------|---------|
106| "I'll just use UIHostingController, it's simple" | Hosting has sizing, lifecycle, and navigation edge cases. `skills/uikit-bridging.md` covers the gotchas. |
107| "Auto Layout error is just a warning, I'll ignore it" | Unsatisfied constraints cause unpredictable layout at runtime. Fix them now. |
108| "I know how CAAnimation works" | 90% of CAAnimation bugs are CATransaction timing, not Core Animation. Check `skills/uikit-animation-debugging.md`. |
109| "Combine is dead, just rewrite with async/await" | Combine has no deprecation notice. Rewriting working pipelines wastes time. `skills/combine-patterns.md` covers when to migrate vs maintain. |
110| "TextKit 1 still works fine" | TextKit 1 misses Writing Tools integration and has known layout bugs Apple won't fix. See `skills/textkit-ref.md`. |
111| "I'll store cancellables in a local variable" | Local AnyCancellable deallocates immediately, killing the subscription. |
112| "I'll archive the PKCanvasView to save the drawing" | Archiving the view loses editability. Persist `drawing.dataRepresentation()`. See `skills/pencilkit-paperkit.md`. |
113| "My tool picker won't show, the API must be broken" | The canvas must `becomeFirstResponder()` after `setVisible(_:forFirstResponder:)`. See `skills/pencilkit-paperkit.md`. |
114
115## Example Invocations
116
117User: "How do I wrap a UIKit view in SwiftUI?"
118→ Read: `skills/uikit-bridging.md`
119
120User: "I'm getting 'Unable to simultaneously satisfy constraints'"
121→ Read: `skills/auto-layout-debugging.md`
122
123User: "My CAAnimation completion handler never fires"
124→ Read: `skills/uikit-animation-debugging.md`
125
126User: "Should I use Combine or async/await for this?"
127→ Read: `skills/combine-patterns.md`
128
129User: "How do I integrate Writing Tools with my text editor?"
130→ Read: `skills/textkit-ref.md`
131
132User: "How do I add an Apple Pencil drawing canvas with the tool picker?"
133→ Read: `skills/pencilkit-paperkit.md`
134
135User: "How do I add a PaperKit markup canvas with shapes and text?"
136→ Read: `skills/pencilkit-paperkit-ref.md`
137
138User: "My SwiftUI view has a memory leak from a Combine subscription"
139→ Read: `skills/combine-patterns.md`
140
141User: "How do I embed SwiftUI in my UIKit app?"
142→ Read: `skills/uikit-bridging.md`
143
144User: "Audit my app for screen resizing support"
145→ `axiom-audit-resize` (or `axiom-audit-resize`)
146
147User: "My custom pinch gesture stops working when the app runs in iPhone Mirroring"
148→ Read: `skills/uikit-modernization.md`
149
150User: "How do I vary my collection view's column count with the window width?"
151→ Read: `skills/adaptive-layout.md`