From cab5466cf926c018928d5e06f6c242ed10dadbf9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 14:49:58 +0000 Subject: [PATCH] Restrict advanced volume capacity properties to iOS only, keep basic properties for both iOS and tvOS Co-authored-by: Zandor300 <6069593+Zandor300@users.noreply.github.com> --- Source/Device.generated.swift | 10 +++++++--- Source/Device.swift.gyb | 10 +++++++--- Tests/Tests.swift | 8 +++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Source/Device.generated.swift b/Source/Device.generated.swift index 94b6c83..d8f3765 100644 --- a/Source/Device.generated.swift +++ b/Source/Device.generated.swift @@ -2118,21 +2118,25 @@ extension Device { public static var volumeAvailableCapacity: Int? { return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityKey]))?.volumeAvailableCapacity } +} +#endif +#if os(iOS) +extension Device { /// The volume’s available capacity in bytes for storing important resources. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumeAvailableCapacityForImportantUsage: Int64? { return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey]))?.volumeAvailableCapacityForImportantUsage } /// The volume’s available capacity in bytes for storing nonessential resources. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumeAvailableCapacityForOpportunisticUsage: Int64? { //swiftlint:disable:this identifier_name return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForOpportunisticUsageKey]))?.volumeAvailableCapacityForOpportunisticUsage } /// All volumes capacity information in bytes. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumes: [URLResourceKey: Int64]? { do { let values = try rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey, diff --git a/Source/Device.swift.gyb b/Source/Device.swift.gyb index db41807..dc0c654 100644 --- a/Source/Device.swift.gyb +++ b/Source/Device.swift.gyb @@ -1259,21 +1259,25 @@ extension Device { public static var volumeAvailableCapacity: Int? { return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityKey]))?.volumeAvailableCapacity } +} +#endif +#if os(iOS) +extension Device { /// The volume’s available capacity in bytes for storing important resources. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumeAvailableCapacityForImportantUsage: Int64? { return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey]))?.volumeAvailableCapacityForImportantUsage } /// The volume’s available capacity in bytes for storing nonessential resources. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumeAvailableCapacityForOpportunisticUsage: Int64? { //swiftlint:disable:this identifier_name return (try? rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForOpportunisticUsageKey]))?.volumeAvailableCapacityForOpportunisticUsage } /// All volumes capacity information in bytes. - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) public static var volumes: [URLResourceKey: Int64]? { do { let values = try rootURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey, diff --git a/Tests/Tests.swift b/Tests/Tests.swift index 3e4dc04..3cce097 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -595,18 +595,20 @@ class DeviceKitTests: XCTestCase { func testVolumeAvailableCapacity() { XCTAssertNotNil(Device.volumeAvailableCapacity) } + #endif - @available(iOS 11.0, tvOS 11.0, *) + #if os(iOS) + @available(iOS 11.0, *) func testVolumeAvailableCapacityForImportantUsage() { XCTAssertNotNil(Device.volumeAvailableCapacityForImportantUsage) } - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) func testVolumeAvailableCapacityForOpportunisticUsage() { XCTAssertNotNil(Device.volumeAvailableCapacityForOpportunisticUsage) } - @available(iOS 11.0, tvOS 11.0, *) + @available(iOS 11.0, *) func testVolumes() { XCTAssertNotNil(Device.volumes) }