apple/swift-metrics

'Duration' is only available in tvOS 16.0 or newer

nuke-dash opened this issue · 2 comments

Expected behavior

This repo compiles for tvOS.

@available is using tvOS 15 but it should be tvOS 16

From Swift // Misc

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
@frozen public struct Duration : Sendable {

From swift-metrics // Metrics // Metrics.swift

extension Timer {
    /// Convenience for recording a duration based on ``Duration``.
    ///
    /// `Duration` will be converted to an `Int64` number of nanoseconds, and then recorded with nanosecond precision.
    ///
    /// - Parameters:
    ///     - duration: The `Duration` to record.
    ///
    /// - Throws: `TimerError.durationToIntOverflow` if conversion from `Duration` to `Int64` of Nanoseconds overflowed.
    @available(macOS 13, iOS 16, tvOS 15, watchOS 8, *)
    @inlinable
    public func record(_ duration: Duration) {
        // `Duration` doesn't have a nice way to convert it nanoseconds or seconds,
        // and manual conversion can overflow.
        let seconds = duration.components.seconds.multipliedReportingOverflow(by: 1_000_000_000)
        guard !seconds.overflow else { return self.recordNanoseconds(Int64.max) }

        let nanoseconds = seconds.partialValue.addingReportingOverflow(duration.components.attoseconds / 1_000_000_000)
        guard !nanoseconds.overflow else { return self.recordNanoseconds(Int64.max) }

        self.recordNanoseconds(nanoseconds.partialValue)
    }
}

Actual behavior

This repo does not compile.

'Duration' is only available in tvOS 16.0 or newer
'components' is only available in tvOS 16.0 or newer

Steps to reproduce

Use the latest release 2.4.3
compile for tvOS

If possible, minimal yet complete reproducer code (or URL to code)

[anything to help us reproducing the issue]

SwiftMetrics version/commit hash

https://github.com/apple/swift-metrics/releases/tag/2.4.3

Swift & OS version (output of swift --version && uname -a)

Xcode 15.3

swift --version && uname -a
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Darwin XXX-Mac-Studio.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020 arm64

Thanks for reporting, that's unfortunate that we didn't notice in 2.4.2.

You could adjust a PR or I'll follow up shortly.

watchOS is also wrong, it's 9+