swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

Add watchOS support

Open jverkoey opened this issue 2 years ago • 4 comments

E.g. the .image Diffing strategy is only available when #if os(iOS) || os(tvOS). This means the strategy is unavailable in os(watchOS) targets.

jverkoey avatar Feb 06 '23 07:02 jverkoey

It looks like one are that might prove tricky is the absence of CoreImage.CIKernel on the watch. perceptuallyCompare relies on this framework.

jverkoey avatar Feb 06 '23 07:02 jverkoey

No perceptual precision, but otherwise I have something working here.

johankool avatar Sep 27 '23 22:09 johankool

Just to confirm, there is no watchOS support in this snapshot testing for SwiftUI VIew's presently, right? E.g.,

assertSnapshot(of: view, as: .image(layout: .sizeThatFits))

works on iOS but will not compile on watchOS. i..e, I get the following

Cannot infer contextual base in reference to member 'sizeThatFits'
Generic parameter 'Format' could not be inferred
Type 'Snapshotting<ExampleView, _>' has no member 'image'

cprince-foreflight avatar Nov 10 '23 21:11 cprince-foreflight

@cprince-foreflight That's right, the library itself doesn't support watchOS. This is because the feature that is used to compare images that only slightly differ uses API that isn't available on watchOS. In my comment above I link to a version that is based on another way to create the images, and lacks the ability to compare slightly different images, but does work on watchOS. I've not yet taken that PR out of draft as I haven't used it "in anger" since.

johankool avatar Nov 13 '23 07:11 johankool