diff --git a/Sources/SHFirestoreService/Combine+FutureHelpers.swift b/Sources/SHFirestoreService/Combine+FutureHelpers.swift index 7974d9b..ea8ff86 100644 --- a/Sources/SHFirestoreService/Combine+FutureHelpers.swift +++ b/Sources/SHFirestoreService/Combine+FutureHelpers.swift @@ -10,6 +10,9 @@ import Foundation #if canImport(Combine) && os(iOS) && swift(>=5.0) import Combine +@available(swift 5.0) +@available(iOS 13.0, *) + public extension Publisher where Output == Void, Failure == FirestoreServiceError { func sink(promise: @escaping Future.Promise) -> AnyCancellable { diff --git a/Sources/SHFirestoreService/Combine+Helpers.swift b/Sources/SHFirestoreService/Combine+Helpers.swift index 07b8857..8d46380 100644 --- a/Sources/SHFirestoreService/Combine+Helpers.swift +++ b/Sources/SHFirestoreService/Combine+Helpers.swift @@ -10,6 +10,9 @@ import Foundation #if canImport(Combine) && os(iOS) && swift(>=5.0) import Combine +@available(swift 5.0) +@available(iOS 13.0, *) + internal extension Publisher { func subscribeAndReceive( on queue: DispatchQueue @@ -17,4 +20,14 @@ internal extension Publisher { return self.subscribe(on: queue).receive(on: queue) } } + +internal extension Publisher where Failure == Error { + func convertFirestoreServiceError( + ) -> Publishers.MapError { + return self.mapError { error in + FirestoreServiceError.wrappedfirestoreError(error) + } + } +} + #endif diff --git a/Sources/SHFirestoreService/SHFirestoreHelpers.swift b/Sources/SHFirestoreService/SHFirestoreHelpers.swift index 8aee459..75277c0 100644 --- a/Sources/SHFirestoreService/SHFirestoreHelpers.swift +++ b/Sources/SHFirestoreService/SHFirestoreHelpers.swift @@ -5,22 +5,17 @@ // Created by μ–‘μŠΉν˜„ on 4/24/24. // +#if os(iOS) && swift(>=5.0) import Foundation -import Combine -internal extension Publisher where Failure == Error { - func convertFirestoreServiceError( - ) -> Publishers.MapError { - return self.mapError { error in - FirestoreServiceError.wrappedfirestoreError(error) - } - } -} +@available(swift 5.0) +@available(iOS 13.0, *) internal extension Encodable { - func toDictionary() throws -> [String: Any] { + typealias Dictionary = [String: Any] + func toDictionary() throws -> Dictionary { let data = try JSONEncoder().encode(self) - guard let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any] else { + guard let dict = try JSONSerialization.jsonObject(with: data) as? Dictionary else { throw Swift.EncodingError.invalidValue( self, Swift.EncodingError.Context.init( @@ -30,3 +25,5 @@ internal extension Encodable { return dict } } + +#endif