diff --git a/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift b/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift index 4267490..6444b43 100644 --- a/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift +++ b/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift @@ -52,7 +52,7 @@ public class AppKitRenderingStrategy: RenderingStrategy { let image = vc?.view.snapshot() completion( SnapshotResult( - image: image != nil ? .success(image!) : .failure(SwiftUIRenderingError.renderingError), + image: image != nil ? .success(image!) : .failure(RenderingError.failedRendering(vc?.view.bounds.size ?? .zero)), precision: precision, accessibilityEnabled: accessibilityEnabled, accessibilityMarkers: nil, diff --git a/Sources/SnapshotPreviewsCore/SwiftUIRenderingStrategy.swift b/Sources/SnapshotPreviewsCore/SwiftUIRenderingStrategy.swift index 01123ba..a45ed0f 100644 --- a/Sources/SnapshotPreviewsCore/SwiftUIRenderingStrategy.swift +++ b/Sources/SnapshotPreviewsCore/SwiftUIRenderingStrategy.swift @@ -8,10 +8,6 @@ import Foundation import SwiftUI -enum SwiftUIRenderingError: Error { - case renderingError -} - @available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, visionOS 1.0, *) public class SwiftUIRenderingStrategy: RenderingStrategy { @@ -41,7 +37,7 @@ public class SwiftUIRenderingStrategy: RenderingStrategy { if let image { completion(SnapshotResult(image: .success(image), precision: wrappedView.precision, accessibilityEnabled: wrappedView.accessibilityEnabled, accessibilityMarkers: [], colorScheme: colorScheme, appStoreSnapshot: wrappedView.appStoreSnapshot)) } else { - completion(SnapshotResult(image: .failure(SwiftUIRenderingError.renderingError), precision: wrappedView.precision, accessibilityEnabled: wrappedView.accessibilityEnabled, accessibilityMarkers: [], colorScheme: colorScheme, appStoreSnapshot: wrappedView.appStoreSnapshot)) + completion(SnapshotResult(image: .failure(RenderingError.failedRendering(.zero)), precision: wrappedView.precision, accessibilityEnabled: wrappedView.accessibilityEnabled, accessibilityMarkers: [], colorScheme: colorScheme, appStoreSnapshot: wrappedView.appStoreSnapshot)) } } } diff --git a/Sources/SnapshotPreviewsCore/View+Snapshot.swift b/Sources/SnapshotPreviewsCore/View+Snapshot.swift index cfbe2d5..e9d07ef 100644 --- a/Sources/SnapshotPreviewsCore/View+Snapshot.swift +++ b/Sources/SnapshotPreviewsCore/View+Snapshot.swift @@ -5,12 +5,7 @@ // Created by Noah Martin on 12/22/22. // -#if canImport(UIKit) && !os(visionOS) && !os(watchOS) && !os(tvOS) -import Foundation -import SwiftUI -import UIKit -import AccessibilitySnapshotCore -import SnapshotSharedModels +import CoreFoundation public enum RenderingError: Error { case failedRendering(CGSize) @@ -18,6 +13,13 @@ public enum RenderingError: Error { case expandingViewTimeout(CGSize) } +#if canImport(UIKit) && !os(visionOS) && !os(watchOS) && !os(tvOS) +import Foundation +import SwiftUI +import UIKit +import AccessibilitySnapshotCore +import SnapshotSharedModels + extension AccessibilityMarker: AccessibilityMark { public var accessibilityShape: MarkerShape { switch shape {