From 53dfb0c6f927740d147372a1d7c7e02f55331dc1 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Thu, 22 Aug 2024 16:27:50 -0400 Subject: [PATCH] Use fixed size rather than nsscreen (#174) --- DemoApp/DemoApp.xcodeproj/project.pbxproj | 9 +++++++++ .../SnapshotPreviewsCore/AppKitRenderingStrategy.swift | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DemoApp/DemoApp.xcodeproj/project.pbxproj b/DemoApp/DemoApp.xcodeproj/project.pbxproj index 9cd9986d..b4191490 100644 --- a/DemoApp/DemoApp.xcodeproj/project.pbxproj +++ b/DemoApp/DemoApp.xcodeproj/project.pbxproj @@ -829,6 +829,11 @@ }; FA8F8B802C66C4C4007CEA33 /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilters = ( + ios, + maccatalyst, + macos, + ); target = FA1671BE2A5367A800A42DB0 /* DemoApp */; targetProxy = FA8F8B7F2C66C4C4007CEA33 /* PBXContainerItemProxy */; }; @@ -1245,6 +1250,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.emerge.DemoAppTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1265,6 +1272,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.emerge.DemoAppTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift b/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift index 6bb6447f..8976ecd2 100644 --- a/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift +++ b/Sources/SnapshotPreviewsCore/AppKitRenderingStrategy.swift @@ -99,7 +99,7 @@ final class AppKitContainer: NSHostingController { heightAnchor = view.heightAnchor.constraint(equalToConstant: height) heightAnchor?.isActive = true default: - let fittingSize = sizeThatFits(in: NSScreen.main!.frame.size) + let fittingSize = sizeThatFits(in: NSSize(width: 800, height: 200)) widthAnchor = view.widthAnchor.constraint(greaterThanOrEqualToConstant: fittingSize.width) widthAnchor?.isActive = true heightAnchor = view.heightAnchor.constraint(greaterThanOrEqualToConstant: fittingSize.height)