Przeglądaj źródła

Add concurrency spec / module.

Jon Shier 3 lat temu
rodzic
commit
60316226f4

+ 1 - 1
.ruby-version

@@ -1 +1 @@
-3.0.3
+3.1.1

+ 67 - 0
.swiftpm/xcode/xcshareddata/xcschemes/Alamofire.xcscheme

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1330"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "Alamofire"
+               BuildableName = "Alamofire"
+               BlueprintName = "Alamofire"
+               ReferencedContainer = "container:">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "Alamofire"
+            BuildableName = "Alamofire"
+            BlueprintName = "Alamofire"
+            ReferencedContainer = "container:">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 67 - 0
.swiftpm/xcode/xcshareddata/xcschemes/AlamofireConcurrency.xcscheme

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1330"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "AlamofireConcurrency"
+               BuildableName = "AlamofireConcurrency"
+               BlueprintName = "AlamofireConcurrency"
+               ReferencedContainer = "container:">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "AlamofireConcurrency"
+            BuildableName = "AlamofireConcurrency"
+            BlueprintName = "AlamofireConcurrency"
+            ReferencedContainer = "container:">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 7 - 2
Alamofire.podspec

@@ -5,7 +5,7 @@ Pod::Spec.new do |s|
   s.summary = 'Elegant HTTP Networking in Swift'
   s.homepage = 'https://github.com/Alamofire/Alamofire'
   s.authors = { 'Alamofire Software Foundation' => 'info@alamofire.org' }
-  s.source = { :git => 'https://github.com/Alamofire/Alamofire.git', :tag => s.version }
+  s.source = { :git => '.' }
   s.documentation_url = 'https://alamofire.github.io/Alamofire/'
 
   s.ios.deployment_target = '10.0'
@@ -13,9 +13,14 @@ Pod::Spec.new do |s|
   s.tvos.deployment_target = '10.0'
   s.watchos.deployment_target = '3.0'
 
-  s.swift_versions = ['5.3', '5.4', '5.5']
+  s.swift_versions = ['5.3', '5.4', '5.5', '5.6']
 
   s.source_files = 'Source/*.swift'
+  s.exclude_files = 'Source/AlamofireConcurrency/Concurrency.swift'
+
+  s.subspec 'Concurrency' do |sp|
+    sp.source_files = 'Source/AlamofireConcurrency/Concurrency.swift'
+  end
 
   s.frameworks = 'CFNetwork'
 end

+ 12 - 12
Gemfile.lock

@@ -3,7 +3,7 @@ GEM
   specs:
     CFPropertyList (3.0.5)
       rexml
-    activesupport (6.1.4.1)
+    activesupport (6.1.5)
       concurrent-ruby (~> 1.0, >= 1.0.2)
       i18n (>= 1.6, < 2)
       minitest (>= 5.1)
@@ -15,11 +15,11 @@ GEM
       httpclient (~> 2.8, >= 2.8.3)
       json (>= 1.5.1)
     atomos (0.1.3)
-    claide (1.0.3)
-    cocoapods (1.11.2)
+    claide (1.1.0)
+    cocoapods (1.11.3)
       addressable (~> 2.8)
       claide (>= 1.0.2, < 2.0)
-      cocoapods-core (= 1.11.2)
+      cocoapods-core (= 1.11.3)
       cocoapods-deintegrate (>= 1.0.3, < 2.0)
       cocoapods-downloader (>= 1.4.0, < 2.0)
       cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -34,7 +34,7 @@ GEM
       nap (~> 1.0)
       ruby-macho (>= 1.0, < 3.0)
       xcodeproj (>= 1.21.0, < 2.0)
-    cocoapods-core (1.11.2)
+    cocoapods-core (1.11.3)
       activesupport (>= 5.0, < 7)
       addressable (~> 2.8)
       algoliasearch (~> 1.0)
@@ -54,18 +54,18 @@ GEM
       netrc (~> 0.11)
     cocoapods-try (1.2.0)
     colored2 (3.1.2)
-    concurrent-ruby (1.1.9)
+    concurrent-ruby (1.1.10)
     escape (0.0.4)
     ethon (0.15.0)
       ffi (>= 1.15.0)
-    ffi (1.15.4)
+    ffi (1.15.5)
     fourflusher (2.3.1)
     fuzzy_match (2.0.4)
     gh_inspector (1.1.3)
     httpclient (2.8.3)
-    i18n (1.8.11)
+    i18n (1.10.0)
       concurrent-ruby (~> 1.0)
-    jazzy (0.14.1)
+    jazzy (0.14.2)
       cocoapods (~> 1.5)
       mustache (~> 1.1)
       open4 (~> 1.3)
@@ -77,7 +77,7 @@ GEM
       xcinvoke (~> 0.3.0)
     json (2.6.1)
     liferaft (0.0.6)
-    minitest (5.14.4)
+    minitest (5.15.0)
     molinillo (0.8.0)
     mustache (1.1.1)
     nanaimo (0.3.0)
@@ -107,7 +107,7 @@ GEM
       rexml (~> 3.2.4)
     xcpretty (0.3.0)
       rouge (~> 2.0.7)
-    zeitwerk (2.5.1)
+    zeitwerk (2.5.4)
 
 PLATFORMS
   ruby
@@ -118,4 +118,4 @@ DEPENDENCIES
   xcpretty
 
 BUNDLED WITH
-   2.2.32
+   2.3.7

+ 7 - 3
Package.swift

@@ -31,18 +31,22 @@ let package = Package(name: "Alamofire",
                                   .tvOS(.v10),
                                   .watchOS(.v3)],
                       products: [.library(name: "Alamofire",
-                                          targets: ["Alamofire"])],
+                                          targets: ["Alamofire"]),
+                                 .library(name: "AlamofireConcurrency",
+                                          targets: ["AlamofireConcurrency"])],
                       targets: [.target(name: "Alamofire",
                                         path: "Source",
-                                        exclude: ["Info.plist"],
+                                        exclude: ["Info.plist", "AlamofireConcurrency"],
                                         linkerSettings: [.linkedFramework("CFNetwork",
                                                                           .when(platforms: [.iOS,
                                                                                             .macOS,
                                                                                             .tvOS,
                                                                                             .watchOS]))]),
+                                .target(name: "AlamofireConcurrency",
+                                        dependencies: ["Alamofire"]),
                                 .testTarget(name: "AlamofireTests",
                                             dependencies: ["Alamofire"],
                                             path: "Tests",
-                                            exclude: ["Info.plist", "Test Plans"],
+                                            exclude: ["ConcurrencyTests.swift", "Info.plist", "Test Plans"],
                                             resources: [.process("Resources")])],
                       swiftLanguageVersions: [.v5])

+ 7 - 3
Package@swift-5.5.swift

@@ -31,18 +31,22 @@ let package = Package(name: "Alamofire",
                                   .tvOS(.v10),
                                   .watchOS(.v3)],
                       products: [.library(name: "Alamofire",
-                                          targets: ["Alamofire"])],
+                                          targets: ["Alamofire"]),
+                                 .library(name: "AlamofireConcurrency",
+                                          targets: ["AlamofireConcurrency"])],
                       targets: [.target(name: "Alamofire",
                                         path: "Source",
-                                        exclude: ["Info.plist"],
+                                        exclude: ["Info.plist", "AlamofireConcurrency"],
                                         linkerSettings: [.linkedFramework("CFNetwork",
                                                                           .when(platforms: [.iOS,
                                                                                             .macOS,
                                                                                             .tvOS,
                                                                                             .watchOS]))]),
+                                .target(name: "AlamofireConcurrency",
+                                        dependencies: ["Alamofire"]),
                                 .testTarget(name: "AlamofireTests",
                                             dependencies: ["Alamofire"],
                                             path: "Tests",
-                                            exclude: ["Info.plist", "Test Plans"],
+                                            exclude: ["ConcurrencyTests.swift", "Info.plist", "Test Plans"],
                                             resources: [.process("Resources")])],
                       swiftLanguageVersions: [.v5])

+ 4 - 1
Source/Concurrency.swift → Source/AlamofireConcurrency/Concurrency.swift

@@ -24,6 +24,9 @@
 
 #if compiler(>=5.5.2) && canImport(_Concurrency)
 
+#if SWIFT_PACKAGE
+import Alamofire
+#endif
 import Foundation
 
 // MARK: - Request Event Streams
@@ -101,7 +104,7 @@ extension Request {
         StreamOf<T>(bufferingPolicy: bufferingPolicy) { [unowned self] continuation in
             yielder(continuation)
             // Must come after serializers run in order to catch retry progress.
-            onFinish {
+            _onFinish {
                 continuation.finish()
             }
         }

+ 3 - 1
Source/Request.swift

@@ -924,8 +924,10 @@ public class Request {
 
     /// Adds a `finishHandler` closure to be called when the request completes.
     ///
+    /// - Note: This is only public because SPM requires it for the AlamofireConcurrency module. It should not be used.
+    ///
     /// - Parameter closure: Closure to be called when the request finishes.
-    func onFinish(perform finishHandler: @escaping () -> Void) {
+    public func _onFinish(perform finishHandler: @escaping () -> Void) {
         guard !isFinished else { finishHandler(); return }
 
         $mutableState.write { state in