From b2a6f819d49dc145a7adb1ec388482e9e7f7af32 Mon Sep 17 00:00:00 2001 From: gambit1185_church Date: Mon, 1 Jun 2026 11:34:10 -0600 Subject: [PATCH] feat: add visionOS support Declare `.visionOS(.v1)` in Package.swift (bumping swift-tools-version to 5.9, the minimum that supports the visionOS platform) and resolve the on-screen positioning by deriving bounds from the active UIWindowScene's coordinate space under `#if os(visionOS)`. Supersedes elai950/AlertToast#104 and #87 (the latter only added the screen branch without the Package.swift platform declaration). Resolves elai950/AlertToast#86. Co-Authored-By: derwaldgeist Co-Authored-By: Claude Opus 4.8 (1M context) --- 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..a3ebe7e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.9 // 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 ac7d99d..71d9e19 100644 --- a/Sources/AlertToast/AlertToast.swift +++ b/Sources/AlertToast/AlertToast.swift @@ -442,6 +442,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