Skip to content

Commit da2fb21

Browse files
authored
Add debug logs when preview cannot be created (#242)
1 parent e7b0879 commit da2fb21

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Checkout code
4242
uses: actions/checkout@v2
4343
- name: Xcode select
44-
run: sudo xcode-select -s '/Applications/Xcode_16.0.app/Contents/Developer'
44+
run: sudo xcode-select -s '/Applications/Xcode_16.4.app/Contents/Developer'
4545
- name: Build TestApp
4646
run: cd Examples && xcodebuild build -scheme DemoApp -sdk xrsimulator -destination 'generic/platform=visionOS Simulator' -project DemoApp/DemoApp.xcodeproj
4747
- name: Build Snapshotting

Sources/SnapshotPreviewsCore/SnapshotPreviewsCore.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public struct Preview: Identifiable {
4242
self.orientation = orientation
4343
self.layout = layout
4444
displayName = preview.descendant("displayName") as? String
45-
let source = preview.descendant("source") ?? preview.descendant("dataSource", "preview")!
45+
guard let source = preview.descendant("source") ?? preview.descendant("dataSource", "preview") else {
46+
assertionFailure("Preview \(preview) missing source, found: \(preview.children)")
47+
return nil
48+
}
4649
let _view: @MainActor () -> any View
4750
if let source = source as? MakeViewProvider {
4851
_view = {
@@ -59,9 +62,11 @@ public struct Preview: Identifiable {
5962
return UIViewControllerWrapper(source.makeViewController)
6063
}
6164
} else {
65+
print("Preview \(preview) (\(displayName ?? "no display name")) did not have matching source type")
6266
return nil
6367
}
6468
#else
69+
print("Preview \(preview) (\(displayName ?? "no display name")) did not have matching source type")
6570
return nil
6671
#endif
6772
}

0 commit comments

Comments
 (0)