Sentry Snapshots for Apple/Cocoa
Scope
- Goal: generate Apple snapshot images and upload them to Sentry Snapshots.
- Detect existing snapshot generation first, including Point-Free
swift-snapshot-testing; preserve it when it already emits or can emit PNGs or JPEGs.
- Use the Sentry Wizard
appleSnapshots flow only when setting up Sentry’s first-party
SnapshotPreviews solution.
- Use manual setup only if the wizard is unavailable, cannot resolve targets
non-interactively after disambiguation, or fails after explicit disambiguation.
- Package-only SwiftPM: stop and ask for the host app/test target; standalone
swift test rendering is not supported.
Detect
Do only enough detection to route before calling the wizard:
# SnapshotPreviews (Sentry first-party) -> prefer wizard / SnapshotPreviews routing
find . \( -name Package.swift -o -name Package.resolved -o -path '*/project.pbxproj' \) -print0 2>/dev/null | xargs -0 grep -lE "SnapshotPreviews" 2>/dev/null
# Point-Free swift-snapshot-testing -> preserve generator, swift-snapshot-testing CI path
find . \( -name Package.swift -o -name Package.resolved -o -path '*/project.pbxproj' \) -print0 2>/dev/null | xargs -0 grep -lE "swift-snapshot-testing|SnapshotTesting|assertSnapshot|__Snapshots__|TEST_RUNNER_SNAPSHOT_TESTING_RECORD" 2>/dev/null
# Required wizard input
find . -name '*.xcodeproj' -print 2>/dev/null | head -20
# Workflow shape
ls fastlane/Fastfile Gemfile 2>/dev/null
# Sentry auth presence only -> never print secret values
[ -n "$SENTRY_AUTH_TOKEN" ] && echo "SENTRY_AUTH_TOKEN=set" || echo "SENTRY_AUTH_TOKEN=unset"
[ -n "$SENTRY_ORG" ] && echo "SENTRY_ORG=set" || echo "SENTRY_ORG=unset"
[ -n "$SENTRY_PROJECT" ] && echo "SENTRY_PROJECT=set" || echo "SENTRY_PROJECT=unset"
Record: existing SnapshotPreviews setup, existing snapshot generator/library, output
directory if known, Xcode project directory, CI provider, Fastlane, and Sentry auth.
For each .xcodeproj match, record the containing directory for --xcode-project-dir;
if find prints ./MyApp/MyApp.xcodeproj, pass ./MyApp, not the bundle path.
Let the wizard detect app targets, hosted XCTest targets, and Swift previews only when
no existing generator is present.
Route
Resolve routing in this order; setup is the primary path and CI is optional follow-up.
- Select or create the image generator:
- named generator wins;
- multiple existing generators with no user choice -> ask;
- existing non-SnapshotPreviews generator -> preserve it;
- existing SnapshotPreviews -> use it;
- no existing generator -> set up SnapshotPreviews by default for Sentry Snapshots or
Apple snapshot testing.
- For SnapshotPreviews, stop before setup/verification/CI if there is no
.xcodeproj
host app or no hosted XCTest target.
These stops do not apply when preserving another generator.
- For setup or verification:
- existing non-SnapshotPreviews generator -> read
references/snapshots.md;
- existing SnapshotPreviews -> read
references/snapshot-previews.md and
references/snapshots.md;
- new SnapshotPreviews setup -> read
references/wizard-setup.md;
- wizard reports no Swift previews -> ask before adding previews or choosing another
generator.
- For GitHub Actions/CI only after an image generator exists:
- Point-Free
swift-snapshot-testing -> read
references/github-actions-swift-snapshot-testing.md and
references/snapshots.md;
- other non-SnapshotPreviews generator -> read
references/snapshots.md and adapt
existing CI/upload;
- SnapshotPreviews, one simulator only, no matrix/fanout/selective CI -> read
references/github-actions-simple.md;
- SnapshotPreviews with multiple simulators, device families, matrix, or any
selective CI -> read
references/github-actions-fanout.md and
references/snapshot-previews.md.
Optional References
| Need |
Read |
| First-party SnapshotPreviews setup, disambiguation, or manual fallback |
references/wizard-setup.md |
| SnapshotPreviews metadata, rendering preferences, selective rendering, or SnapshotPreviews-specific troubleshooting |
references/snapshot-previews.md |
Upload any generated snapshot images to Sentry with Fastlane, sentry-cli, manifests, CI notes, or upload troubleshooting |
references/snapshots.md |
| One-destination GitHub Actions workflow |
references/github-actions-simple.md |
| Multi-destination/fan-out GitHub Actions workflow |
references/github-actions-fanout.md |
Point-Free swift-snapshot-testing GitHub Actions workflow |
references/github-actions-swift-snapshot-testing.md |
Completion Checks
- The selected snapshot image generator is documented and preserved or configured
according to the route above.
- Snapshot generation appears in the relevant local or CI test logs.
- Export directory contains
.png files and any generated .json sidecars.
- Upload succeeds and prints a Sentry URL or snapshot id.
- Base branch upload is full; selective PR upload includes the full image-name manifest.
1---2name: sentry-snapshots-cocoa3description: Full Sentry Snapshots setup for Apple/Cocoa projects. Use when asked to "setup SnapshotPreviews", "setup Apple snapshot testing", "upload Apple snapshots to Sentry", "setup Apple snapshot GitHub Actions", or "setup Apple selective snapshot testing".4license: Apache-2.05---6# Sentry Snapshots for Apple/Cocoa
7
8## Scope
9
10- Goal: generate Apple snapshot images and upload them to Sentry Snapshots.
11- Detect existing snapshot generation first, including Point-Free
12 `swift-snapshot-testing`; preserve it when it already emits or can emit PNGs or JPEGs.
13- Use the Sentry Wizard `appleSnapshots` flow only when setting up Sentry’s first-party
14 SnapshotPreviews solution.
15- Use manual setup only if the wizard is unavailable, cannot resolve targets
16 non-interactively after disambiguation, or fails after explicit disambiguation.
17- Package-only SwiftPM: stop and ask for the host app/test target; standalone
18 `swift test` rendering is not supported.
19
20## Detect
21
22Do only enough detection to route before calling the wizard:
23
24```bash
25# SnapshotPreviews (Sentry first-party) -> prefer wizard / SnapshotPreviews routing
26find . \( -name Package.swift -o -name Package.resolved -o -path '*/project.pbxproj' \) -print0 2>/dev/null | xargs -0 grep -lE "SnapshotPreviews" 2>/dev/null
27
28# Point-Free swift-snapshot-testing -> preserve generator, swift-snapshot-testing CI path
29find . \( -name Package.swift -o -name Package.resolved -o -path '*/project.pbxproj' \) -print0 2>/dev/null | xargs -0 grep -lE "swift-snapshot-testing|SnapshotTesting|assertSnapshot|__Snapshots__|TEST_RUNNER_SNAPSHOT_TESTING_RECORD" 2>/dev/null
30
31# Required wizard input
32find . -name '*.xcodeproj' -print 2>/dev/null | head -20
33
34# Workflow shape
35ls fastlane/Fastfile Gemfile 2>/dev/null
36
37# Sentry auth presence only -> never print secret values
38[ -n "$SENTRY_AUTH_TOKEN" ] && echo "SENTRY_AUTH_TOKEN=set" || echo "SENTRY_AUTH_TOKEN=unset"
39[ -n "$SENTRY_ORG" ] && echo "SENTRY_ORG=set" || echo "SENTRY_ORG=unset"
40[ -n "$SENTRY_PROJECT" ] && echo "SENTRY_PROJECT=set" || echo "SENTRY_PROJECT=unset"
41```
42
43Record: existing SnapshotPreviews setup, existing snapshot generator/library, output
44directory if known, Xcode project directory, CI provider, Fastlane, and Sentry auth.
45For each `.xcodeproj` match, record the containing directory for `--xcode-project-dir`;
46if `find` prints `./MyApp/MyApp.xcodeproj`, pass `./MyApp`, not the bundle path.
47Let the wizard detect app targets, hosted XCTest targets, and Swift previews only when
48no existing generator is present.
49
50## Route
51
52Resolve routing in this order; setup is the primary path and CI is optional follow-up.
53
541. Select or create the image generator:
55 - named generator wins;
56 - multiple existing generators with no user choice -> ask;
57 - existing non-SnapshotPreviews generator -> preserve it;
58 - existing SnapshotPreviews -> use it;
59 - no existing generator -> set up SnapshotPreviews by default for Sentry Snapshots or
60 Apple snapshot testing.
612. For SnapshotPreviews, stop before setup/verification/CI if there is no `.xcodeproj`
62 host app or no hosted XCTest target.
63 These stops do not apply when preserving another generator.
643. For setup or verification:
65 - existing non-SnapshotPreviews generator -> read `references/snapshots.md`;
66 - existing SnapshotPreviews -> read `references/snapshot-previews.md` and
67 `references/snapshots.md`;
68 - new SnapshotPreviews setup -> read `references/wizard-setup.md`;
69 - wizard reports no Swift previews -> ask before adding previews or choosing another
70 generator.
714. For GitHub Actions/CI only after an image generator exists:
72 - Point-Free `swift-snapshot-testing` -> read
73 `references/github-actions-swift-snapshot-testing.md` and
74 `references/snapshots.md`;
75 - other non-SnapshotPreviews generator -> read `references/snapshots.md` and adapt
76 existing CI/upload;
77 - SnapshotPreviews, one simulator only, no matrix/fanout/selective CI -> read
78 `references/github-actions-simple.md`;
79 - SnapshotPreviews with multiple simulators, device families, matrix, or any
80 selective CI -> read `references/github-actions-fanout.md` and
81 `references/snapshot-previews.md`.
82
83## Optional References
84
85| Need | Read |
86| --- | --- |
87| First-party SnapshotPreviews setup, disambiguation, or manual fallback | `references/wizard-setup.md` |
88| SnapshotPreviews metadata, rendering preferences, selective rendering, or SnapshotPreviews-specific troubleshooting | `references/snapshot-previews.md` |
89| Upload any generated snapshot images to Sentry with Fastlane, `sentry-cli`, manifests, CI notes, or upload troubleshooting | `references/snapshots.md` |
90| One-destination GitHub Actions workflow | `references/github-actions-simple.md` |
91| Multi-destination/fan-out GitHub Actions workflow | `references/github-actions-fanout.md` |
92| Point-Free `swift-snapshot-testing` GitHub Actions workflow | `references/github-actions-swift-snapshot-testing.md` |
93
94## Completion Checks
95
96- The selected snapshot image generator is documented and preserved or configured
97 according to the route above.
98- Snapshot generation appears in the relevant local or CI test logs.
99- Export directory contains `.png` files and any generated `.json` sidecars.
100- Upload succeeds and prints a Sentry URL or snapshot id.
101- Base branch upload is full; selective PR upload includes the full image-name manifest.