Browse Source

Okay, this has to be all of them.

Jon Shier 2 years ago
parent
commit
096d138bcf
4 changed files with 7 additions and 6 deletions
  1. 2 1
      Source/RequestTaskMap.swift
  2. 3 3
      Source/Session.swift
  3. 1 1
      Tests/TestHelpers.swift
  4. 1 1
      Tests/WebSocketTests.swift

+ 2 - 1
Source/RequestTaskMap.swift

@@ -131,7 +131,8 @@ struct RequestTaskMap {
 
         switch (events.completed, events.metricsGathered) {
         case (true, _): fatalError("RequestTaskMap consistency error: duplicate completionReceivedForTask call.")
-        #if os(Linux) || os(Android) // Linux doesn't gather metrics, so unconditionally remove the reference and return true.
+        // swift-corelibs-foundation doesn't gather metrics, so unconditionally remove the reference and return true.
+        #if canImport(FoundationNetworking)
         default: self[task] = nil; return true
         #else
         case (false, false):

+ 3 - 3
Source/Session.swift

@@ -461,7 +461,7 @@ open class Session {
         return request
     }
 
-    #if !(os(Linux) || os(Windows))
+    #if canImport(Darwin) && !canImport(FoundationNetworking)
     @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
     open func websocketRequest(to convertible: URLRequestConvertible,
                                protocol: String? = nil,
@@ -1027,7 +1027,7 @@ open class Session {
                 case let r as DownloadRequest: self.performDownloadRequest(r)
                 case let r as DataStreamRequest: self.performDataStreamRequest(r)
                 default:
-                    #if !(os(Linux) || os(Windows))
+                    #if canImport(Darwin) && !canImport(FoundationNetworking)
                     if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *),
                        let request = request as? WebSocketRequest {
                         self.performWebSocketRequest(request)
@@ -1054,7 +1054,7 @@ open class Session {
         performSetupOperations(for: request, convertible: request.convertible)
     }
 
-    #if !(os(Linux) || os(Windows))
+    #if canImport(Darwin) && !canImport(FoundationNetworking)
     @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
     func performWebSocketRequest(_ request: WebSocketRequest) {
         dispatchPrecondition(condition: .onQueue(requestQueue))

+ 1 - 1
Tests/TestHelpers.swift

@@ -234,7 +234,7 @@ struct Endpoint {
 
     static let upload: Endpoint = .init(path: .upload, method: .post, headers: [.contentType("application/octet-stream")])
 
-    #if !(os(Linux) || os(Windows))
+    #if canImport(Darwin) && !canImport(FoundationNetworking)
     static var defaultCloseDelay: Int64 {
         if #available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) {
             return 0

+ 1 - 1
Tests/WebSocketTests.swift

@@ -6,7 +6,7 @@
 //  Copyright © 2021 Alamofire. All rights reserved.
 //
 
-#if !(os(Linux) || os(Windows))
+#if canImport(Darwin) && !canImport(FoundationNetworking)
 
 import Alamofire
 import Foundation