Skip to content

Commit

Permalink
Removed Unused Availability Attributes in Functions
Browse files Browse the repository at this point in the history
* Since `Package.swift` already limits Functions support to Catalyst 13, macOS 10.15, tvOS 13, and watchOS 7, explicit checks for these versions aren’t needed
* `@available` attributes and `#available` checks for iOS 13 remain in place
  • Loading branch information
yakovmanshin committed Oct 13, 2024
1 parent 26841da commit ba72363
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions FirebaseFunctions/Sources/Callable+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
/// - Throws: An error if the callable fails to complete
///
/// - Returns: The decoded `Response` value
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
public func call(_ data: Request) async throws -> Response {
let encoded = try encoder.encode(data)
let result = try await callable.call(encoded)
Expand All @@ -155,7 +155,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
/// - Parameters:
/// - data: Parameters to pass to the trigger.
/// - Returns: The decoded `Response` value
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
public func callAsFunction(_ data: Request) async throws -> Response {
return try await call(data)
}
Expand Down
2 changes: 1 addition & 1 deletion FirebaseFunctions/Sources/HTTPSCallable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ open class HTTPSCallable: NSObject {
/// - Parameter data: Parameters to pass to the trigger.
/// - Throws: An error if the Cloud Functions invocation failed.
/// - Returns: The result of the call.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
open func call(_ data: Any? = nil) async throws -> HTTPSCallableResult {
return try await withCheckedThrowingContinuation { continuation in
// TODO(bonus): Use task to handle and cancellation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class HTTPSCallableResultFake: HTTPSCallableResult {
}
}

@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 6.0, *)
@available(iOS 13, *)
class HTTPSCallableTests: XCTestCase {
func testCallWithoutParametersSuccess() {
// given
Expand Down
30 changes: 15 additions & 15 deletions FirebaseFunctions/Tests/Integration/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testDataAsync() async throws {
let data = DataTestRequest(
bool: true,
Expand Down Expand Up @@ -173,7 +173,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testScalarAsync() async throws {
let byName = functions.httpsCallable(
"scalarTest",
Expand All @@ -192,7 +192,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testScalarAsyncAlternateSignature() async throws {
let byName: Callable<Int16, Int> = functions.httpsCallable("scalarTest")
let byURL: Callable<Int16, Int> = functions.httpsCallable(emulatorURL("scalarTest"))
Expand Down Expand Up @@ -240,7 +240,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testTokenAsync() async throws {
// Recreate functions with a token.
let functions = Functions(
Expand Down Expand Up @@ -296,7 +296,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testFCMTokenAsync() async throws {
let byName = functions.httpsCallable(
"FCMTokenTest",
Expand Down Expand Up @@ -341,7 +341,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testNullAsync() async throws {
let byName = functions.httpsCallable(
"nullTest",
Expand Down Expand Up @@ -390,7 +390,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testMissingResultAsync() async {
let byName = functions.httpsCallable(
"missingResultTest",
Expand Down Expand Up @@ -444,7 +444,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testUnhandledErrorAsync() async {
let byName = functions.httpsCallable(
"unhandledErrorTest",
Expand Down Expand Up @@ -497,7 +497,7 @@ class IntegrationTests: XCTestCase {
waitForExpectations(timeout: 5)
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testUnknownErrorAsync() async {
let byName = functions.httpsCallable(
"unknownErrorTest",
Expand Down Expand Up @@ -552,7 +552,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testExplicitErrorAsync() async {
let byName = functions.httpsCallable(
"explicitErrorTest",
Expand Down Expand Up @@ -607,7 +607,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testHttpErrorAsync() async {
let byName = functions.httpsCallable(
"httpErrorTest",
Expand Down Expand Up @@ -660,7 +660,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testThrowErrorAsync() async {
let byName = functions.httpsCallable(
"throwTest",
Expand Down Expand Up @@ -715,7 +715,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testTimeoutAsync() async {
var byName = functions.httpsCallable(
"timeoutTest",
Expand Down Expand Up @@ -777,7 +777,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testCallAsFunctionAsync() async throws {
let data = DataTestRequest(
bool: true,
Expand Down Expand Up @@ -840,7 +840,7 @@ class IntegrationTests: XCTestCase {
}
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(iOS 13, *)
func testInferredTyesAsync() async throws {
let data = DataTestRequest(
bool: true,
Expand Down
4 changes: 2 additions & 2 deletions FirebaseFunctions/Tests/Unit/FunctionsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class FunctionsAPITests: XCTestCase {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
if #available(iOS 13, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
Expand All @@ -105,7 +105,7 @@ final class FunctionsAPITests: XCTestCase {
}
}

if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
if #available(iOS 13, *) {
// async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
Task {
do {
Expand Down

0 comments on commit ba72363

Please sign in to comment.