Set platforms that allow back deployment of concurrency
This commit is contained in:
parent
6d2751d326
commit
418a245f21
2 changed files with 5 additions and 6 deletions
|
@ -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"]),
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue