diff --git a/Package.swift b/Package.swift index 5d3b22d..5979824 100644 --- a/Package.swift +++ b/Package.swift @@ -6,11 +6,10 @@ import PackageDescription let package = Package( name: "AsyncBackports", platforms: [ - // TODO: Xcode 13.2 set targets where backport available - .macOS(.v12), - .iOS(.v15), - .watchOS(.v8), - .tvOS(.v15), + .macOS(.v10_15), + .iOS(.v13), + .watchOS(.v6), + .tvOS(.v13), ], products: [ .library(name: "AsyncBackports", targets: ["AsyncBackports"]), diff --git a/Sources/AsyncBackports/URLSession+Backport.swift b/Sources/AsyncBackports/URLSession+Backport.swift index 0c7becd..c0f501a 100644 --- a/Sources/AsyncBackports/URLSession+Backport.swift +++ b/Sources/AsyncBackports/URLSession+Backport.swift @@ -18,6 +18,7 @@ public extension Backport where Original: URLSession { if #available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) { return try await original.data(for: request, delegate: delegate) } else { + precondition(delegate == nil, "Cannot set delegate") return try await withUnsafeThrowingContinuation { continuation in let task = URLSession.shared.dataTask(with: request) { data, response, error in if let data = data, let response = response { @@ -28,7 +29,6 @@ public extension Backport where Original: URLSession { fatalError("Neither response nor error") } } - task.delegate = delegate task.resume() } }