Browse Source

Update styling, fix warnings by setting the swift migration value, turn off @objc inference.

Jon Shier 8 years ago
parent
commit
8e85284b58

+ 9 - 7
Alamofire.xcodeproj/project.pbxproj

@@ -908,31 +908,31 @@
 					};
 					4CF626EE1BA7CB3E0011A099 = {
 						CreatedOnToolsVersion = 7.1;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 					4CF626F71BA7CB3E0011A099 = {
 						CreatedOnToolsVersion = 7.1;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 					4DD67C0A1A5C55C900ED2280 = {
 						CreatedOnToolsVersion = 6.1.1;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 						ProvisioningStyle = Manual;
 					};
 					E4202FCD1B667AA100C997FB = {
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 					F8111E3219A95C8B0040E7D1 = {
 						CreatedOnToolsVersion = 6.0;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 					F8111E3D19A95C8B0040E7D1 = {
 						CreatedOnToolsVersion = 6.0;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 					F829C6B11A7A94F100A2CD59 = {
 						CreatedOnToolsVersion = 6.1.1;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 				};
 			};
@@ -1557,6 +1557,7 @@
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_SWIFT3_OBJC_INFERENCE = Off;
 				SWIFT_VERSION = 3.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -1613,6 +1614,7 @@
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+				SWIFT_SWIFT3_OBJC_INFERENCE = Off;
 				SWIFT_VERSION = 3.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 9.0;

+ 3 - 3
Example/iOS Example.xcodeproj/project.pbxproj

@@ -211,7 +211,7 @@
 				TargetAttributes = {
 					F8111E0419A951050040E7D1 = {
 						CreatedOnToolsVersion = 6.0;
-						LastSwiftMigration = 0800;
+						LastSwiftMigration = 0900;
 					};
 				};
 			};
@@ -387,6 +387,7 @@
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_SWIFT3_OBJC_INFERENCE = Off;
 				SWIFT_VERSION = 3.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -436,6 +437,7 @@
 				MACOSX_DEPLOYMENT_TARGET = 10.11;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
+				SWIFT_SWIFT3_OBJC_INFERENCE = Off;
 				SWIFT_VERSION = 3.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -456,7 +458,6 @@
 				PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.iOS-Example";
 				PRODUCT_NAME = "iOS Example";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 3.0;
 			};
 			name = Debug;
 		};
@@ -472,7 +473,6 @@
 				PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.iOS-Example";
 				PRODUCT_NAME = "iOS Example";
 				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
-				SWIFT_VERSION = 3.0;
 			};
 			name = Release;
 		};

+ 3 - 3
Source/ParameterEncoding.swift

@@ -241,11 +241,11 @@ public struct URLEncoding: ParameterEncoding {
             let value = parameters[key]!
             components += queryComponents(fromKey: key, value: value)
         }
-        #if swift(>=4.0)
+    #if swift(>=4.0)
         return components.map { "\($0.0)=\($0.1)" }.joined(separator: "&")
-        #else
+    #else
         return components.map { "\($0)=\($1)" }.joined(separator: "&")
-        #endif
+    #endif
     }
 
     private func encodesParametersInURL(with method: HTTPMethod) -> Bool {

+ 6 - 6
Source/SessionManager.swift

@@ -58,18 +58,18 @@ open class SessionManager {
         let acceptEncoding: String = "gzip;q=1.0, compress;q=0.5"
 
         // Accept-Language HTTP Header; see https://tools.ietf.org/html/rfc7231#section-5.3.5
-        #if swift(>=4.0)
-            let acceptLanguage = Locale.preferredLanguages.prefix(6).enumerated().map { enumeratedLanguage in
-                let (index, languageCode) = enumeratedLanguage
-                let quality = 1.0 - (Double(index) * 0.1)
+    #if swift(>=4.0)
+        let acceptLanguage = Locale.preferredLanguages.prefix(6).enumerated().map { enumeratedLanguage in
+            let (index, languageCode) = enumeratedLanguage
+            let quality = 1.0 - (Double(index) * 0.1)
             return "\(languageCode);q=\(quality)"
         }.joined(separator: ", ")
-        #else
+    #else
         let acceptLanguage = Locale.preferredLanguages.prefix(6).enumerated().map { index, languageCode in
             let quality = 1.0 - (Double(index) * 0.1)
             return "\(languageCode);q=\(quality)"
         }.joined(separator: ", ")
-        #endif
+    #endif
 
         // User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3
         // Example: `iOS Example/1.0 (org.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0`

+ 6 - 4
Tests/ResponseTests.swift

@@ -277,8 +277,9 @@ class ResponseJSONTestCase: BaseTestCase {
         }
 
         if
-            let responseDictionary = response?.result.value as? [String : Any],
-            let args = responseDictionary["args"] as? [String : String] {
+            let responseDictionary = response?.result.value as? [String: Any],
+            let args = responseDictionary["args"] as? [String: String]
+        {
             XCTAssertEqual(args, ["foo": "bar"], "args should match parameters")
         } else {
             XCTFail("args should not be nil")
@@ -312,8 +313,9 @@ class ResponseJSONTestCase: BaseTestCase {
         }
 
         if
-            let responseDictionary = response?.result.value as? [String : Any],
-            let form = responseDictionary["form"] as? [String : String] {
+            let responseDictionary = response?.result.value as? [String: Any],
+            let form = responseDictionary["form"] as? [String: String]
+        {
             XCTAssertEqual(form, ["foo": "bar"], "form should match parameters")
         } else {
             XCTFail("form should not be nil")

+ 3 - 3
Tests/SessionManagerTests.swift

@@ -787,12 +787,12 @@ class SessionManagerConfigurationHeadersTestCase: BaseTestCase {
         // Given, When, Then
         executeAuthorizationHeaderTest(for: .ephemeral)
     }
-    #if os(macOS)
+#if os(macOS)
     func testThatBackgroundConfigurationHeadersAreSentWithRequest() {
         // Given, When, Then
         executeAuthorizationHeaderTest(for: .background)
     }
-    #endif
+#endif
 
     private func executeAuthorizationHeaderTest(for type: ConfigurationType) {
         // Given
@@ -841,7 +841,7 @@ class SessionManagerConfigurationHeadersTestCase: BaseTestCase {
             XCTAssertTrue(response.result.isSuccess, "result should be a success")
 
             if
-                let response = response.result.value as? [String : Any],
+                let response = response.result.value as? [String: Any],
                 let headers = response["headers"] as? [String: String],
                 let authorization = headers["Authorization"]
             {

+ 22 - 19
Tests/UploadTests.swift

@@ -533,7 +533,7 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
         }
     }
 
-    #if os(macOS)
+#if os(macOS)
     func testThatUploadingMultipartFormDataOnBackgroundSessionWritesDataToFileToAvoidCrash() {
         // Given
         let manager: SessionManager = {
@@ -556,27 +556,30 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
         var streamingFromDisk: Bool?
 
         // When
-        manager.upload(multipartFormData: { multipartFormData in
-            multipartFormData.append(french, withName: "french")
-            multipartFormData.append(japanese, withName: "japanese")
-        }, to: urlString,
-           encodingCompletion: { result in
-            switch result {
-            case let .success(upload, uploadStreamingFromDisk, _):
-                streamingFromDisk = uploadStreamingFromDisk
-
-                upload.response { defaultResponse in
-                    request = defaultResponse.request
-                    response = defaultResponse.response
-                    data = defaultResponse.data
-                    error = defaultResponse.error
+        manager.upload(
+            multipartFormData: { multipartFormData in
+                multipartFormData.append(french, withName: "french")
+                multipartFormData.append(japanese, withName: "japanese")
+            },
+            to: urlString,
+            encodingCompletion: { result in
+                switch result {
+                case let .success(upload, uploadStreamingFromDisk, _):
+                    streamingFromDisk = uploadStreamingFromDisk
 
+                    upload.response { defaultResponse in
+                        request = defaultResponse.request
+                        response = defaultResponse.response
+                        data = defaultResponse.data
+                        error = defaultResponse.error
+
+                        expectation.fulfill()
+                    }
+                case .failure:
                     expectation.fulfill()
                 }
-            case .failure:
-                expectation.fulfill()
             }
-        })
+        )
 
         waitForExpectations(timeout: timeout, handler: nil)
 
@@ -592,7 +595,7 @@ class UploadMultipartFormDataTestCase: BaseTestCase {
             XCTFail("streaming from disk should not be nil")
         }
     }
-    #endif
+#endif
 
     // MARK: Combined Test Execution