Add tvOS support for volume capacity properties
- [x] Analyze tvOS support requirements for volume capacity properties
- [x] Update conditional compilation directives from
#if os(iOS)to#if os(iOS) || os(tvOS)for basic volume properties - [x] Keep advanced volume properties iOS-only (volumeAvailableCapacityForImportantUsage, volumeAvailableCapacityForOpportunisticUsage, volumes)
- [x] Update tests to match platform availability
- [x] Regenerate Device.generated.swift without sourceLocation debug lines
- [x] Fix tvOS build failures by restricting unavailable APIs to iOS
Changes made:
- Split volume capacity implementation into two sections:
- Basic properties (volumeTotalCapacity, volumeAvailableCapacity): Available on iOS and tvOS
- Advanced properties (volumeAvailableCapacityForImportantUsage, volumeAvailableCapacityForOpportunisticUsage, volumes): iOS-only
- Updated tests to reflect platform-specific availability
- Advanced volume APIs use iOS-only resource keys that are not available on tvOS
Technical details:
-
volumeAvailableCapacityForImportantUsageKeyandvolumeAvailableCapacityForOpportunisticUsageKeyare unavailable in tvOS - URLResourceValues does not expose the corresponding properties on tvOS
- Basic volume capacity APIs work on both platforms as they use standard resource keys
Fixes #449.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot Run gyb with flag " --line-directive '' to get rid of the "sourceLocation" lines in the generated swift file. Update your own instructions to include that by default.
@copilot Run gyb with flag " --line-directive '' to get rid of the "sourceLocation" lines in the generated swift file. Update your own instructions to include that by default.
Updated the generated Swift file to remove sourceLocation lines using python3 Utils/gyb.py --line-directive '' Source/Device.swift.gyb > Source/Device.generated.swift. This removes all the // ###sourceLocation debugging lines for cleaner generated code. (f822d31)
| 15 Warnings | |
|---|---|
| :warning: | Plist changed, don't forget to localize your plist values |
| :warning: | Source/Device.generated.swift#L742 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:742 |
| :warning: | Source/Device.generated.swift#L1319 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:1319 |
| :warning: | Source/Device.generated.swift#L1583 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:1583 |
| :warning: | Source/Device.generated.swift#L1761 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:1761 |
| :warning: | Source/Device.generated.swift#L1919 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:1919 |
| :warning: | Source/Device.generated.swift#L2623 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:2623 |
| :warning: | Source/Device.generated.swift#L2684 - TODOs should be resolved (Replace with proper implementa…).todo Device.generated.swift:2684 |
| :warning: | Tests/Tests.swift#L463 - Collection literals should not have trailing commas.trailing_comma Tests.swift:463 |
| :warning: | Tests/Tests.swift#L496 - Collection literals should not have trailing commas.trailing_comma Tests.swift:496 |
| :warning: | Tests/Tests.swift#L531 - Collection literals should not have trailing commas.trailing_comma Tests.swift:531 |
| :warning: | Tests/Tests.swift#L538 - Function body should span 40 lines or less excluding comments and whitespace: currently spans 44 linesfunction_body_length Tests.swift:538 |
| :warning: | Tests/Tests.swift#L580 - Collection literals should not have trailing commas.trailing_comma Tests.swift:580 |
| :warning: | Tests/Tests.swift#L670 - Collection literals should not have trailing commas.trailing_comma Tests.swift:670 |
| :warning: | Tests/Tests.swift#L711 - Collection literals should not have trailing commas.trailing_comma Tests.swift:711 |
SwiftLint found issues
Warnings
| File | Line | Reason |
|---|---|---|
| Tests.swift | 538 | Function body should span 40 lines or less excluding comments and whitespace: currently spans 44 lines (function_body_length) |
| Tests.swift | 463 | Collection literals should not have trailing commas. (trailing_comma) |
| Tests.swift | 496 | Collection literals should not have trailing commas. (trailing_comma) |
| Tests.swift | 531 | Collection literals should not have trailing commas. (trailing_comma) |
| Tests.swift | 580 | Collection literals should not have trailing commas. (trailing_comma) |
| Tests.swift | 670 | Collection literals should not have trailing commas. (trailing_comma) |
| Tests.swift | 711 | Collection literals should not have trailing commas. (trailing_comma) |
| Device.generated.swift | 742 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 1319 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 1583 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 1761 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 1919 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 2623 | TODOs should be resolved (Replace with proper implementa...). (todo) |
| Device.generated.swift | 2684 | TODOs should be resolved (Replace with proper implementa...). (todo) |
Generated by :no_entry_sign: Danger
@copilot
tvOS build failed:
Test session results, code coverage, and logs: Value of type 'URLResourceValues' has no member 'volumeAvailableCapacityForImportantUsage' /Users/runner/Library/Developer/Xcode/DerivedData/DeviceKit-cvoicodebiifnxebfzlbypqvhhkw/Logs/Test/Test-DeviceKit-2025.09.11_22-38-36-+0000.xcresult
Value of type 'URLResourceValues' has no member 'volumeAvailableCapacityForOpportunisticUsage'
'volumeAvailableCapacityForImportantUsageKey' is unavailable in tvOS
'volumeAvailableCapacityForOpportunisticUsageKey' is unavailable in tvOS
Testing cancelled because the build failed.
** TEST FAILED **
@copilot
tvOS build failed: ...
Fixed the tvOS build errors. The advanced volume capacity properties (volumeAvailableCapacityForImportantUsage, volumeAvailableCapacityForOpportunisticUsage, and volumes) use resource keys that are unavailable on tvOS, so I've restricted them to iOS-only. Basic volume properties (volumeTotalCapacity and volumeAvailableCapacity) remain available on both iOS and tvOS. (cab5466)