From d608282ae53b9bf2e14c8a5b67c89927ba5d7afe Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Thu, 13 Mar 2025 10:23:22 +0000 Subject: [PATCH] Add missing availability annotations to fix iOS, watchOS, and tvOS builds (#233) ### Motivation Currently this package doesn't build for the non-macOS Apple platforms. For example, compiling for iOS fails with: - `error: 'some' return types are only available in iOS 13.0.0 or newer` - `error: Concurrency is only available in iOS 13.0.0 or newer` Looks like a few types were missing the availability annotations when this package switched to using them and dropping the minimum platform requirement. ### Modifications - Add missing annotations to restore build. ### Results - Package now builds on iOS, tvOS, and watchOS. - `struct NameConstraints`, `struct NameConstraintsValue` are marked only available on iOS 13+ etc. - `protocol OCSPRequester` is marked only available on iOS 13+ etc. --- Sources/X509/Extension Types/NameConstraints.swift | 6 ++++++ Sources/X509/OCSP/OCSPPolicy.swift | 1 + 2 files changed, 7 insertions(+) diff --git a/Sources/X509/Extension Types/NameConstraints.swift b/Sources/X509/Extension Types/NameConstraints.swift index e10eaa2..56d7464 100644 --- a/Sources/X509/Extension Types/NameConstraints.swift +++ b/Sources/X509/Extension Types/NameConstraints.swift @@ -23,6 +23,7 @@ import SwiftASN1 /// Restrictions are defined in terms of both permitted and forbidden subtrees. The forbidden trees /// are consulted first, and if a name is matched in a forbidden tree then it does not matter whether /// the same name is also matched in a permitted tree. +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) public struct NameConstraints { public struct DNSNames: Hashable, Sendable, Collection, ExpressibleByArrayLiteral, CustomStringConvertible { public typealias Element = String @@ -689,10 +690,13 @@ extension Hasher { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension NameConstraints: Hashable {} +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension NameConstraints: Sendable {} +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension NameConstraints: CustomStringConvertible { public var description: String { var elements: [String] = [] @@ -712,6 +716,7 @@ extension NameConstraints: CustomStringConvertible { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension NameConstraints: CustomDebugStringConvertible { public var debugDescription: String { return "NameConstraints(\(String(describing: self)))" @@ -743,6 +748,7 @@ extension NameConstraints: CertificateExtensionConvertible { // MARK: ASN1 Helpers @usableFromInline +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) struct NameConstraintsValue: DERImplicitlyTaggable { @inlinable static var defaultIdentifier: ASN1Identifier { diff --git a/Sources/X509/OCSP/OCSPPolicy.swift b/Sources/X509/OCSP/OCSPPolicy.swift index 2d8b828..a2bd487 100644 --- a/Sources/X509/OCSP/OCSPPolicy.swift +++ b/Sources/X509/OCSP/OCSPPolicy.swift @@ -25,6 +25,7 @@ import Foundation // Swift CI has implicit concurrency disabled import _Concurrency +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) public protocol OCSPRequester: Sendable { /// Called with an OCSP Request. ///