Skip to content

Commit

Permalink
Merge pull request #78 from nerdishbynature/enable-macos
Browse files Browse the repository at this point in the history
Enable async/await on macOS
  • Loading branch information
pietbrauer authored Jan 1, 2022
2 parents cfc435b + 8c1eac4 commit e266fd8
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ on:
jobs:
macOS:
name: Test macOS
runs-on: macOS-11
runs-on: macOS-latest
env:
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
strategy:
matrix:
include:
Expand Down
6 changes: 3 additions & 3 deletions Sources/RequestKit/JSONPostRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public protocol JSONPostRouter: Router {
func postJSON<T>(_ session: RequestKitURLSession, expectedResultType: T.Type, completion: @escaping (_ json: T?, _ error: Error?) -> Void) -> URLSessionDataTaskProtocol?
func post<T: Codable>(_ session: RequestKitURLSession, decoder: JSONDecoder, expectedResultType: T.Type, completion: @escaping (_ json: T?, _ error: Error?) -> Void) -> URLSessionDataTaskProtocol?

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func postJSON<T>(_ session: RequestKitURLSession, expectedResultType: T.Type) async throws -> T?

Expand Down Expand Up @@ -62,7 +62,7 @@ public extension JSONPostRouter {
return task
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func postJSON<T>(_ session: RequestKitURLSession = URLSession.shared, expectedResultType: T.Type) async throws -> T? {
guard let request = request() else {
Expand Down Expand Up @@ -130,7 +130,7 @@ public extension JSONPostRouter {
return task
}

#if !canImport(FoundationNetworking) && !os(macOS) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func post<T: Codable>(_ session: RequestKitURLSession, decoder: JSONDecoder = JSONDecoder(), expectedResultType: T.Type) async throws -> T {
guard let request = request() else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/RequestKit/RequestKitSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public protocol RequestKitURLSession {
func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTaskProtocol
func uploadTask(with request: URLRequest, fromData bodyData: Data?, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func data(for request: URLRequest, delegate: URLSessionTaskDelegate?) async throws -> (Data, URLResponse)

Expand Down
2 changes: 1 addition & 1 deletion Sources/RequestKit/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public extension Router {
return task
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func load<T: Codable>(_ session: RequestKitURLSession = URLSession.shared, decoder: JSONDecoder = JSONDecoder(), expectedResultType: T.Type) async throws -> T {
guard let request = request() else {
Expand Down
4 changes: 2 additions & 2 deletions Tests/RequestKitTests/JSONPostRouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class JSONPostRouterTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testJSONPostJSONErrorAsync() async throws {
let jsonDict = ["message": "Bad credentials", "documentation_url": "https://developer.github.com/v3"]
Expand Down Expand Up @@ -56,7 +56,7 @@ class JSONPostRouterTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testJSONPostStringErrorAsync() async throws {
let errorString = "Just nope"
Expand Down
2 changes: 1 addition & 1 deletion Tests/RequestKitTests/RequestKitURLTestSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RequestKitURLTestSession: RequestKitURLSession {
return MockURLSessionDataTask()
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func upload(for request: URLRequest, from data: Data, delegate: URLSessionTaskDelegate?) async throws -> (Data, URLResponse) {
XCTAssertEqual(request.url?.absoluteString, expectedURL)
Expand Down
2 changes: 1 addition & 1 deletion Tests/RequestKitTests/RouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RouterTests: XCTestCase {
XCTAssertTrue(session.wasCalled)
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testErrorWithJSONAsync() async throws {
let jsonDict = ["message": "Bad credentials", "documentation_url": "https://developer.github.com/v3"]
Expand Down
4 changes: 2 additions & 2 deletions Tests/RequestKitTests/TestInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestInterface {
}
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func postJSON(_ session: RequestKitURLSession) async throws -> [String: AnyObject]? {
let router = JSONTestRouter.testPOST(configuration)
Expand All @@ -49,7 +49,7 @@ class TestInterface {
}
}

#if !canImport(FoundationNetworking) && !os(macOS)
#if !canImport(FoundationNetworking)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func getJSON(_ session: RequestKitURLSession) async throws -> [String: String] {
let router = JSONTestRouter.testGET(configuration)
Expand Down
6 changes: 3 additions & 3 deletions fastlane/.env.default
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AF_IOS_SDK=iphonesimulator15.0
AF_MAC_SDK=macosx12.0
AF_TVOS_SDK=appletvsimulator15.0
AF_IOS_SDK=iphonesimulator15.2
AF_MAC_SDK=macosx12.2
AF_TVOS_SDK=appletvsimulator15.2

AF_CONFIGURATION=Release

Expand Down
2 changes: 1 addition & 1 deletion fastlane/.env.ios
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SCAN_DEVICE="iPhone 12 Pro"
SCAN_SDK=iphonesimulator15.0
SCAN_SDK=$AF_IOS_SDK

0 comments on commit e266fd8

Please sign in to comment.