From 0cb9a53f076ec575a94c7d489838cabd581474bf Mon Sep 17 00:00:00 2001 From: Bobby Bobak Date: Mon, 25 Dec 2023 23:58:58 +0000 Subject: [PATCH 1/2] Add support for visionOS - Introduced a versioned Package.swift as per [specification](https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md\#version-specific-manifest-selection) - Added `.visionOS` as a supported platform - Updated handling of the background mode of AVPlayer for visionOS - Disabled `ImageDecoders.Video` as `AVAssetImageGenerator.copyCGImage` is not available for visionOS --- Package.swift | 5 +++-- Package@swift-5.7.swift | 24 +++++++++++++++++++++ Sources/NukeVideo/ImageDecoders+Video.swift | 2 +- Sources/NukeVideo/VideoPlayerView.swift | 6 +++++- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 Package@swift-5.7.swift diff --git a/Package.swift b/Package.swift index ca4aa7df0..e41ee56c3 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.9 import PackageDescription let package = Package( @@ -7,7 +7,8 @@ let package = Package( .iOS(.v13), .tvOS(.v13), .macOS(.v10_15), - .watchOS(.v6) + .watchOS(.v6), + .visionOS(.v1), ], products: [ .library(name: "Nuke", targets: ["Nuke"]), diff --git a/Package@swift-5.7.swift b/Package@swift-5.7.swift new file mode 100644 index 000000000..ca4aa7df0 --- /dev/null +++ b/Package@swift-5.7.swift @@ -0,0 +1,24 @@ +// swift-tools-version:5.7 +import PackageDescription + +let package = Package( + name: "Nuke", + platforms: [ + .iOS(.v13), + .tvOS(.v13), + .macOS(.v10_15), + .watchOS(.v6) + ], + products: [ + .library(name: "Nuke", targets: ["Nuke"]), + .library(name: "NukeUI", targets: ["NukeUI"]), + .library(name: "NukeVideo", targets: ["NukeVideo"]), + .library(name: "NukeExtensions", targets: ["NukeExtensions"]) + ], + targets: [ + .target(name: "Nuke"), + .target(name: "NukeUI", dependencies: ["Nuke"]), + .target(name: "NukeVideo", dependencies: ["Nuke"]), + .target(name: "NukeExtensions", dependencies: ["Nuke"]) + ] +) diff --git a/Sources/NukeVideo/ImageDecoders+Video.swift b/Sources/NukeVideo/ImageDecoders+Video.swift index 94620314a..014989e37 100644 --- a/Sources/NukeVideo/ImageDecoders+Video.swift +++ b/Sources/NukeVideo/ImageDecoders+Video.swift @@ -2,7 +2,7 @@ // // Copyright (c) 2015-2023 Alexander Grebenyuk (github.com/kean). -#if !os(watchOS) +#if !os(watchOS) && !os(visionOS) import Foundation import AVKit diff --git a/Sources/NukeVideo/VideoPlayerView.swift b/Sources/NukeVideo/VideoPlayerView.swift index 2dc0ee1f6..343155196 100644 --- a/Sources/NukeVideo/VideoPlayerView.swift +++ b/Sources/NukeVideo/VideoPlayerView.swift @@ -137,7 +137,11 @@ public final class VideoPlayerView: _PlatformBaseView { let playerItem = AVPlayerItem(asset: asset) let player = AVQueuePlayer(playerItem: playerItem) player.isMuted = true - player.preventsDisplaySleepDuringVideoPlayback = false +#if os(visionOS) + player.preventsAutomaticBackgroundingDuringVideoPlayback = false +#else + player.preventsDisplaySleepDuringVideoPlayback = false +#endif player.actionAtItemEnd = isLooping ? .none : .pause self.player = player From 342cb729394b960b08a42fd0a5ed6fcc19cf1e25 Mon Sep 17 00:00:00 2001 From: Bobby Bobak Date: Wed, 27 Dec 2023 16:52:28 +0000 Subject: [PATCH 2/2] Swap Package.swift versions --- Package.swift | 5 ++--- Package@swift-5.7.swift => Package@swift-5.9.swift | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename Package@swift-5.7.swift => Package@swift-5.9.swift (89%) diff --git a/Package.swift b/Package.swift index e41ee56c3..ca4aa7df0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.9 +// swift-tools-version:5.7 import PackageDescription let package = Package( @@ -7,8 +7,7 @@ let package = Package( .iOS(.v13), .tvOS(.v13), .macOS(.v10_15), - .watchOS(.v6), - .visionOS(.v1), + .watchOS(.v6) ], products: [ .library(name: "Nuke", targets: ["Nuke"]), diff --git a/Package@swift-5.7.swift b/Package@swift-5.9.swift similarity index 89% rename from Package@swift-5.7.swift rename to Package@swift-5.9.swift index ca4aa7df0..e41ee56c3 100644 --- a/Package@swift-5.7.swift +++ b/Package@swift-5.9.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7 +// swift-tools-version:5.9 import PackageDescription let package = Package( @@ -7,7 +7,8 @@ let package = Package( .iOS(.v13), .tvOS(.v13), .macOS(.v10_15), - .watchOS(.v6) + .watchOS(.v6), + .visionOS(.v1), ], products: [ .library(name: "Nuke", targets: ["Nuke"]),