From 40da6a09823c8a9bfa68b6487e92d86b8e8a821e Mon Sep 17 00:00:00 2001 From: Sam Deane Date: Tue, 20 Aug 2024 15:27:12 +0100 Subject: [PATCH] Fixed macOS build --- .../XCTestExtensions/XCUIApplication+UITesting.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/XCTestExtensions/XCUIApplication+UITesting.swift b/Sources/XCTestExtensions/XCUIApplication+UITesting.swift index 572eb08..f4c2b2e 100644 --- a/Sources/XCTestExtensions/XCUIApplication+UITesting.swift +++ b/Sources/XCTestExtensions/XCUIApplication+UITesting.swift @@ -57,7 +57,17 @@ public extension XCUIApplication { var screenshotsURL: URL { let env = ProcessInfo.processInfo.environment let path = env["ScreenshotDirectory"] ?? "\(NSTemporaryDirectory())/Screenshots" - let url = URL(fileURLWithPath: path).appendingPathComponent(UIDevice.current.name) + var url = URL(fileURLWithPath: path) + + let deviceName: String? + #if os(iOS) + deviceName = UIDevice.current.name + #else + deviceName = Host.current().name + #endif + if let deviceName { + url = url.appendingPathComponent(deviceName) + } try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true) return url