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(
|
let package = Package(
|
||||||
name: "AsyncBackports",
|
name: "AsyncBackports",
|
||||||
platforms: [
|
platforms: [
|
||||||
// TODO: Xcode 13.2 set targets where backport available
|
.macOS(.v10_15),
|
||||||
.macOS(.v12),
|
.iOS(.v13),
|
||||||
.iOS(.v15),
|
.watchOS(.v6),
|
||||||
.watchOS(.v8),
|
.tvOS(.v13),
|
||||||
.tvOS(.v15),
|
|
||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
.library(name: "AsyncBackports", targets: ["AsyncBackports"]),
|
.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, *) {
|
if #available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) {
|
||||||
return try await original.data(for: request, delegate: delegate)
|
return try await original.data(for: request, delegate: delegate)
|
||||||
} else {
|
} else {
|
||||||
|
precondition(delegate == nil, "Cannot set delegate")
|
||||||
return try await withUnsafeThrowingContinuation { continuation in
|
return try await withUnsafeThrowingContinuation { continuation in
|
||||||
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
||||||
if let data = data, let response = response {
|
if let data = data, let response = response {
|
||||||
|
@ -28,7 +29,6 @@ public extension Backport where Original: URLSession {
|
||||||
fatalError("Neither response nor error")
|
fatalError("Neither response nor error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task.delegate = delegate
|
|
||||||
task.resume()
|
task.resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue