From 36236f595c854b36cadb7806b8e4d5c94c7b80b6 Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:15:27 +0300 Subject: [PATCH 1/6] made compatible with Alamofire 5.0.0-rc2 --- .../AlamofireObjectMapper.swift | 12 +++---- .../AlamofireObjectMapperTests.swift | 36 +++++++++---------- Cartfile | 4 +-- Cartfile.resolved | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/AlamofireObjectMapper/AlamofireObjectMapper.swift b/AlamofireObjectMapper/AlamofireObjectMapper.swift index 6dc539b..56ad121 100644 --- a/AlamofireObjectMapper/AlamofireObjectMapper.swift +++ b/AlamofireObjectMapper/AlamofireObjectMapper.swift @@ -109,7 +109,7 @@ extension DataRequest { let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath) if let JSONObject = JSONObject, - let parsedObject = (try? Mapper(context: context, shouldIncludeNilValues: false).map(JSONObject: JSONObject)){ + let parsedObject = (try? Mapper(context: context, shouldIncludeNilValues: false).map(JSONObject: JSONObject) as T) { return parsedObject } else { let failureReason = "ObjectMapper failed to serialize response." @@ -129,12 +129,12 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse) -> Void) -> Self { + public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperSerializer(keyPath, mapToObject: object, context: context), completionHandler: completionHandler) } @discardableResult - public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse) -> Void) -> Self { + public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperImmutableSerializer(keyPath, context: context), completionHandler: completionHandler) } @@ -165,7 +165,7 @@ extension DataRequest { if let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath){ - if let parsedObject = try? Mapper(context: context, shouldIncludeNilValues: false).mapArray(JSONObject: JSONObject){ + if let parsedObject = try? Mapper(context: context, shouldIncludeNilValues: false).mapArray(JSONObject: JSONObject) as [T] { return parsedObject } } @@ -185,7 +185,7 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self { + public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse<[T]>) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperArraySerializer(keyPath, context: context), completionHandler: completionHandler) } @@ -199,7 +199,7 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self { + public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse<[T]>) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperImmutableArraySerializer(keyPath, context: context), completionHandler: completionHandler) } } diff --git a/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift b/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift index 1a06fc9..ae877b2 100644 --- a/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift +++ b/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift @@ -49,10 +49,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -78,10 +78,10 @@ class AlamofireObjectMapperTests: XCTestCase { let weatherResponse = WeatherResponse() weatherResponse.date = Date() - _ = Alamofire.request(URL, method: .get).responseObject(mapToObject: weatherResponse) { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(mapToObject: weatherResponse) { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value print(weatherResponse) XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.date, "Date should not be nil") // Date is not in JSON but should not be nil because we mapped onto an existing object with a date set @@ -105,10 +105,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/2ee8f34d21e8febfdefb2b3a403f18a43818d70a/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject(keyPath: "data") { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(keyPath: "data") { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -131,10 +131,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/97231a04e6e4970612efcc0b7e0c125a83e3de6e/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject(keyPath: "response.data") { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(keyPath: "response.data") { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -157,10 +157,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/f583be1121dbc5e9b0381b3017718a70c31054f7/sample_array_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -183,11 +183,11 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray(keyPath: "three_day_forecast") { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray(keyPath: "three_day_forecast") { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -208,11 +208,11 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/97231a04e6e4970612efcc0b7e0c125a83e3de6e/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray(keyPath: "response.data.three_day_forecast") { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray(keyPath: "response.data.three_day_forecast") { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -235,10 +235,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -261,10 +261,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/f583be1121dbc5e9b0381b3017718a70c31054f7/sample_array_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray { (response: DataResponse<[ImmutableForecast]>) in + _ = AF.request(URL, method: .get).responseArray { (response: AFDataResponse<[ImmutableForecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") diff --git a/Cartfile b/Cartfile index b88c036..444b0a7 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" "5.0.0-beta.6" -github "tristanhimmelman/ObjectMapper" ~> 3.4 +github "Alamofire/Alamofire" "5.0.0-rc.2" +github "tristanhimmelman/ObjectMapper" ~> 3.5.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 7bb1668..8ada0d1 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" "5.0.0-beta.6" +github "Alamofire/Alamofire" "5.0.0-rc.2" github "tristanhimmelman/ObjectMapper" "3.5.1" From d9d957b604ea0e6895a3dd928a92737e770c4229 Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:19:18 +0300 Subject: [PATCH 2/6] updated travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1d3b8ce..a507d15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10 +osx_image: xcode10.3 env: global: @@ -20,4 +20,4 @@ script: - xcodebuild -workspace "$XCODE_WORKSPACE" -scheme "$SCHEME" -configuration Release clean build CODE_SIGN_IDENTITY="" BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO | xcpretty -c; notifications: - email: false \ No newline at end of file + email: false From d45f74642ef0e91b1425e444899670798d7ffa94 Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:29:38 +0300 Subject: [PATCH 3/6] updated podspec --- AlamofireObjectMapper.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AlamofireObjectMapper.podspec b/AlamofireObjectMapper.podspec index 8381db4..b893913 100644 --- a/AlamofireObjectMapper.podspec +++ b/AlamofireObjectMapper.podspec @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.requires_arc = true s.source_files = 'AlamofireObjectMapper/**/*.swift' - s.dependency 'Alamofire', '5.0.0-beta.6' - s.dependency 'ObjectMapper', '~> 3.4' + s.dependency 'Alamofire', '5.0.0-rc.2' + s.dependency 'ObjectMapper', '~> 3.5.1' end From abcca40c39d68bef9609ba5958655fd56f4b73ca Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:37:26 +0300 Subject: [PATCH 4/6] made Swift 5.0 compatible --- AlamofireObjectMapper.podspec | 2 +- .../project.pbxproj | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/AlamofireObjectMapper.podspec b/AlamofireObjectMapper.podspec index b893913..8cbec57 100644 --- a/AlamofireObjectMapper.podspec +++ b/AlamofireObjectMapper.podspec @@ -13,7 +13,7 @@ Pod::Spec.new do |s| s.watchos.deployment_target = '3.0' s.tvos.deployment_target = '10.0' - s.swift_version = '4.2' + s.swift_version = '5.0' s.requires_arc = true s.source_files = 'AlamofireObjectMapper/**/*.swift' diff --git a/AlamofireObjectMapper.xcodeproj/project.pbxproj b/AlamofireObjectMapper.xcodeproj/project.pbxproj index 34999b2..ed0a2b9 100644 --- a/AlamofireObjectMapper.xcodeproj/project.pbxproj +++ b/AlamofireObjectMapper.xcodeproj/project.pbxproj @@ -841,7 +841,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -893,7 +893,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -921,7 +921,7 @@ PRODUCT_NAME = AlamofireObjectMapper; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -945,7 +945,7 @@ PRODUCT_NAME = AlamofireObjectMapper; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -966,7 +966,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -984,7 +984,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1013,7 +1013,7 @@ PRODUCT_NAME = AlamofireObjectMapper; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1038,7 +1038,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1061,7 +1061,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1080,7 +1080,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1105,7 +1105,7 @@ PRODUCT_NAME = AlamofireObjectMapper; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 3.0; }; @@ -1132,7 +1132,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 3.0; }; @@ -1159,7 +1159,7 @@ PRODUCT_NAME = AlamofireObjectMapper; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -1186,7 +1186,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -1205,7 +1205,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; @@ -1223,7 +1223,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Release; From 9f880ca1a3b0c9cfee9f1d1382769e0990cf4295 Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:47:37 +0300 Subject: [PATCH 5/6] updated Carthage --- Carthage/Checkouts/Alamofire | 2 +- Carthage/Checkouts/ObjectMapper | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Carthage/Checkouts/Alamofire b/Carthage/Checkouts/Alamofire index e4371be..c1d1458 160000 --- a/Carthage/Checkouts/Alamofire +++ b/Carthage/Checkouts/Alamofire @@ -1 +1 @@ -Subproject commit e4371be5f83354f94dc82227a6c17d5010187087 +Subproject commit c1d14588e5558a3669fd03510d135d88c5109069 diff --git a/Carthage/Checkouts/ObjectMapper b/Carthage/Checkouts/ObjectMapper index 83848fe..19d499c 160000 --- a/Carthage/Checkouts/ObjectMapper +++ b/Carthage/Checkouts/ObjectMapper @@ -1 +1 @@ -Subproject commit 83848fe8baa6fab47c7c325514956d4c9b2b88e6 +Subproject commit 19d499c65b8240f1220d7cf155ccd309857f8018 From 4083eb096f2fa05f6ed26fcb13e11a61e1b5183f Mon Sep 17 00:00:00 2001 From: Ozgur Vatansever Date: Mon, 23 Sep 2019 18:56:08 +0300 Subject: [PATCH 6/6] updated travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a507d15..e15825e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: - SCHEME="AlamofireObjectMapper tvOS" before_install: - - gem install xcpretty --no-rdoc --no-ri --no-document --quiet + - gem install xcpretty --no-document --quiet script: - set -o pipefail