Skip to content

Commit 62fbedd

Browse files
authored
Move platform availability to types (#22)
Motivation: Having `platforms` in `Package.swift` might prevent others from adopting this library. Modifications: - Move platform availability to types - Remove `platforms` in `Package.swift` - macOS 10.15 seems to be sufficient, so lowering it from v13.0
1 parent e8f3efc commit 62fbedd

File tree

9 files changed

+25
-11
lines changed

9 files changed

+25
-11
lines changed

Package.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ do {
2121

2222
let package = Package(
2323
name: "swift-async-dns-resolver",
24-
platforms: [
25-
.macOS("13.0"),
26-
.iOS(.v13),
27-
],
2824
products: [
2925
.library(name: "AsyncDNSResolver", targets: ["AsyncDNSResolver"]),
3026
],

Sources/AsyncDNSResolver/AsyncDNSResolver.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -15,6 +15,7 @@
1515
// MARK: - Async DNS resolver API
1616

1717
/// `AsyncDNSResolver` provides API for running asynchronous DNS queries.
18+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1819
public struct AsyncDNSResolver {
1920
let underlying: DNSResolver
2021

Sources/AsyncDNSResolver/Errors.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -12,6 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1516
extension AsyncDNSResolver {
1617
/// Possible ``AsyncDNSResolver/AsyncDNSResolver`` errors.
1718
public struct Error: Swift.Error, CustomStringConvertible {

Sources/AsyncDNSResolver/c-ares/AresChannel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -17,6 +17,7 @@ import Foundation
1717

1818
// MARK: - ares_channel
1919

20+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
2021
class AresChannel {
2122
let pointer: UnsafeMutablePointer<ares_channel?>
2223
let lock = NSLock()
@@ -62,6 +63,7 @@ class AresChannel {
6263
}
6364
}
6465

66+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
6567
private func checkAresResult(body: () -> Int32) throws {
6668
let result = body()
6769
guard result == ARES_SUCCESS else {

Sources/AsyncDNSResolver/c-ares/AresOptions.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -16,6 +16,7 @@ import CAsyncDNSResolver
1616

1717
// MARK: - Options for `CAresDNSResolver`
1818

19+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1920
extension CAresDNSResolver {
2021
/// Options for ``CAresDNSResolver``.
2122
public struct Options {
@@ -88,6 +89,7 @@ extension CAresDNSResolver {
8889
}
8990
}
9091

92+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
9193
extension CAresDNSResolver.Options {
9294
public struct Flags: OptionSet {
9395
public let rawValue: Int32
@@ -120,6 +122,7 @@ extension CAresDNSResolver.Options {
120122
}
121123
}
122124

125+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
123126
extension CAresDNSResolver.Options {
124127
var aresOptions: AresOptions {
125128
let aresOptions = AresOptions()

Sources/AsyncDNSResolver/c-ares/DNSResolver_c-ares.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import CAsyncDNSResolver
1616

1717
/// ``DNSResolver`` implementation backed by c-ares C library.
18+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1819
public class CAresDNSResolver: DNSResolver {
1920
let options: Options
2021
let ares: Ares
@@ -119,6 +120,7 @@ extension QueryType {
119120

120121
// MARK: - c-ares query wrapper
121122

123+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
122124
class Ares {
123125
typealias QueryCallback = @convention(c) (UnsafeMutableRawPointer?, CInt, CInt, UnsafeMutablePointer<CUnsignedChar>?, CInt) -> Void
124126

@@ -183,6 +185,7 @@ class Ares {
183185
}
184186
}
185187

188+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
186189
extension Ares {
187190
// TODO: implement this more nicely using NIO EventLoop?
188191
// See:
@@ -253,6 +256,7 @@ extension Ares {
253256

254257
// MARK: - c-ares query reply handler
255258

259+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
256260
extension Ares {
257261
struct QueryReplyHandler {
258262
private let _handler: (CInt, UnsafeMutablePointer<CUnsignedChar>?, CInt) -> Void
@@ -291,6 +295,7 @@ protocol AresQueryReplyParser {
291295
func parse(buffer: UnsafeMutablePointer<CUnsignedChar>?, length: CInt) throws -> Reply
292296
}
293297

298+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
294299
extension Ares {
295300
static let maxAddresses: Int = 32
296301

Sources/AsyncDNSResolver/c-ares/Errors_c-ares.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -14,6 +14,7 @@
1414

1515
import CAsyncDNSResolver
1616

17+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1718
extension AsyncDNSResolver.Error {
1819
/// Create an ``AsyncDNSResolver/AsyncDNSResolver/Error`` from c-ares error code.
1920
init(code: Int32, _ description: String? = nil) {

Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the SwiftAsyncDNSResolver open source project
44
//
5-
// Copyright (c) 2023 Apple Inc. and the SwiftAsyncDNSResolver project authors
5+
// Copyright (c) 2023-2024 Apple Inc. and the SwiftAsyncDNSResolver project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -16,6 +16,7 @@
1616
import dnssd
1717

1818
/// ``DNSResolver`` implementation backed by dnssd framework.
19+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
1920
public struct DNSSDDNSResolver: DNSResolver {
2021
let dnssd: DNSSD
2122

@@ -98,6 +99,7 @@ extension QueryType {
9899

99100
// MARK: - dnssd query wrapper
100101

102+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
101103
struct DNSSD {
102104
// Reference: https://gist.github.com/fikeminkel/a9c4bc4d0348527e8df3690e242038d3
103105
func query<ReplyHandler: DNSSDQueryReplyHandler>(
@@ -167,6 +169,7 @@ struct DNSSD {
167169

168170
// MARK: - dnssd query reply handler
169171

172+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
170173
extension DNSSD {
171174
struct QueryReplyHandler {
172175
private let _handleRecord: (DNSServiceErrorType, UnsafeRawPointer?, UInt16) -> Void
@@ -208,6 +211,7 @@ protocol DNSSDQueryReplyHandler {
208211
func generateReply(records: [Record]) throws -> Reply
209212
}
210213

214+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
211215
extension DNSSD {
212216
// Reference: https://github.com/orlandos-nl/DNSClient/blob/master/Sources/DNSClient/Messages/Message.swift
213217

@@ -450,6 +454,7 @@ extension DNSSDQueryReplyHandler {
450454
return parts.isEmpty ? nil : parts.joined(separator: ".")
451455
}
452456

457+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
453458
func ensureOne<R>(records: [R]) throws -> R {
454459
guard records.count <= 1 else {
455460
throw AsyncDNSResolver.Error.badResponse("expected 1 record but got \(records.count)")

scripts/soundness.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1818

1919
function replace_acceptable_years() {
2020
# this needs to replace all acceptable forms with 'YEARS'
21-
sed -e 's/202[012]-202[1234]/YEARS/' -e 's/202[01234]/YEARS/'
21+
sed -e 's/202[0123]-202[1234]/YEARS/' -e 's/202[01234]/YEARS/'
2222
}
2323

2424
if ! hash swiftformat &> /dev/null

0 commit comments

Comments
 (0)