From 116efa4c76b989e595081fe43b0be92f5a574e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Bru=CC=88ckner?= Date: Fri, 22 Nov 2024 13:33:24 +0100 Subject: [PATCH] compatibility to visionOS --- Package.swift | 5 +++-- Sources/AlertToast/AlertToast.swift | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index b259d6f..9ccdc8b 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -7,7 +7,8 @@ let package = Package( name: "AlertToast", platforms: [ .iOS(.v14), - .macOS(.v11) + .macOS(.v11), + .visionOS(.v1) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Sources/AlertToast/AlertToast.swift b/Sources/AlertToast/AlertToast.swift index 17bf751..dd482c7 100644 --- a/Sources/AlertToast/AlertToast.swift +++ b/Sources/AlertToast/AlertToast.swift @@ -436,6 +436,11 @@ public struct AlertToastModifier: ViewModifier{ private var screen: CGRect { #if os(iOS) return UIScreen.main.bounds +#elseif os(visionOS) + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene { + return windowScene.coordinateSpace.bounds + } + return .zero #else return NSScreen.main?.frame ?? .zero #endif