From 85c8731e260904a3c73853b017f531109593a1d1 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Tue, 14 Sep 2021 06:25:17 -0300 Subject: [PATCH 1/2] Add async/await support --- Package.swift | 1 + Sources/PostgREST/Concurrency.swift | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 Sources/PostgREST/Concurrency.swift diff --git a/Package.swift b/Package.swift index e7ba31f..a69f2b7 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,7 @@ import PackageDescription let package = Package( name: "PostgREST", + platforms: [.iOS(.v11), .macOS(.v10_10)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( diff --git a/Sources/PostgREST/Concurrency.swift b/Sources/PostgREST/Concurrency.swift new file mode 100644 index 0000000..c2477fa --- /dev/null +++ b/Sources/PostgREST/Concurrency.swift @@ -0,0 +1,12 @@ +import Foundation + +@available(iOS 15.0.0, macOS 12.0.0, *) +extension PostgrestBuilder { + public func execute(head: Bool = false, count: CountOption? = nil) async throws -> PostgrestResponse { + try await withCheckedThrowingContinuation { continuation in + self.execute(head: head, count: count) { result in + continuation.resume(with: result) + } + } + } +} From c09ab9bd1a63fd8f439bab7fe0fb03110d8b0687 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Wed, 15 Sep 2021 06:09:31 -0300 Subject: [PATCH 2/2] Check for compiler version --- Sources/PostgREST/Concurrency.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/PostgREST/Concurrency.swift b/Sources/PostgREST/Concurrency.swift index c2477fa..70dd89c 100644 --- a/Sources/PostgREST/Concurrency.swift +++ b/Sources/PostgREST/Concurrency.swift @@ -1,5 +1,6 @@ import Foundation +#if compiler(>=5.5) @available(iOS 15.0.0, macOS 12.0.0, *) extension PostgrestBuilder { public func execute(head: Bool = false, count: CountOption? = nil) async throws -> PostgrestResponse { @@ -10,3 +11,4 @@ extension PostgrestBuilder { } } } +#endif