From c43bba8d1378f033ef1903114b8ce46312565b17 Mon Sep 17 00:00:00 2001 From: Julien Regnauld Date: Sun, 27 Sep 2015 10:31:59 +0200 Subject: [PATCH 01/11] Switch git branch to master for submodule Alamofire and SwiftyJSON --- Alamofire | 2 +- SwiftyJSON | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Alamofire b/Alamofire index 0fd77fe..ba280a4 160000 --- a/Alamofire +++ b/Alamofire @@ -1 +1 @@ -Subproject commit 0fd77fec2a33e237ab99069c36410eb7101126c6 +Subproject commit ba280a4fbd591cffb52542ccb6b9897a50604cff diff --git a/SwiftyJSON b/SwiftyJSON index 11fdc5c..3b5d0d4 160000 --- a/SwiftyJSON +++ b/SwiftyJSON @@ -1 +1 @@ -Subproject commit 11fdc5ce7ae0ded6c0fd06790f72f25254a79d14 +Subproject commit 3b5d0d4e0c19173b1bf0dc823bde25ad870f70c0 From 8cb1e134b28efef6d29a8f1682acbb850b7f8630 Mon Sep 17 00:00:00 2001 From: Julien Regnauld Date: Sun, 27 Sep 2015 11:20:49 +0200 Subject: [PATCH 02/11] Fixes #35, Update response for Alamofire 3. completionHandler returns a Response struct instead of request, response, result. --- .../project.pbxproj | 93 +++++++++++++++---- .../Alamofire-SwiftyJSON.xcscmblueprint | 37 ++++++++ Source/Alamofire-SwiftyJSON.swift | 27 +++--- 3 files changed, 129 insertions(+), 28 deletions(-) create mode 100644 Alamofire-SwiftyJSON.xcodeproj/project.xcworkspace/xcshareddata/Alamofire-SwiftyJSON.xcscmblueprint diff --git a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj index b190bc2..18d94a8 100644 --- a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj +++ b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj @@ -18,19 +18,47 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - A8A2DBB21A2328F500AF9EFC /* PBXContainerItemProxy */ = { + 4BC5E9F91BB7E15600A393DD /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; + containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 4EC1C1C91A0C1A2D0026ED0B; - remoteInfo = SwiftyJSONOSX; + remoteGlobalIDString = 4DD67C0B1A5C55C900ED2280; + remoteInfo = "Alamofire OSX"; }; - A8A2DBB41A2328F500AF9EFC /* PBXContainerItemProxy */ = { + 4BC5E9FB1BB7E15600A393DD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = E4202FE01B667AA100C997FB; + remoteInfo = "Alamofire watchOS"; + }; + 4BC5E9FD1BB7E15600A393DD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = F829C6B21A7A94F100A2CD59; + remoteInfo = "Alamofire OSX Tests"; + }; + 4BC5EA031BB7E15600A393DD /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 4EC1C1D31A0C1A2D0026ED0B; - remoteInfo = SwiftyJSONOSXTests; + remoteGlobalIDString = 9C7DFC5B1A9102BD005AA3F7; + remoteInfo = "SwiftyJSON OSX"; + }; + 4BC5EA051BB7E15600A393DD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 9C7DFC651A9102BD005AA3F7; + remoteInfo = "SwiftyJSON OSX Tests"; + }; + 4BC5EA071BB7E15600A393DD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = E4D7CCE81B9465A700EE7221; + remoteInfo = "SwiftyJSON watchOS"; }; A8A2DBB61A23290100AF9EFC /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -214,7 +242,10 @@ isa = PBXGroup; children = ( A8AFB75A19D14A5C0070765E /* Alamofire.framework */, + 4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */, + 4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */, A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */, + 4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */, ); name = Products; sourceTree = ""; @@ -224,8 +255,9 @@ children = ( A8AFB76519D14A670070765E /* SwiftyJSON.framework */, A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */, - A8A2DBB31A2328F500AF9EFC /* SwiftyJSON.framework */, - A8A2DBB51A2328F500AF9EFC /* SwiftyJSONOSXTests.xctest */, + 4BC5EA041BB7E15600A393DD /* SwiftyJSON.framework */, + 4BC5EA061BB7E15600A393DD /* SwiftyJSON OSX Tests.xctest */, + 4BC5EA081BB7E15600A393DD /* SwiftyJSON.framework */, ); name = Products; sourceTree = ""; @@ -292,6 +324,7 @@ A8AFB70619D1401D0070765E /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0600; ORGANIZATIONNAME = SwiftJSON; TargetAttributes = { @@ -332,18 +365,46 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - A8A2DBB31A2328F500AF9EFC /* SwiftyJSON.framework */ = { + 4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Alamofire.framework; + remoteRef = 4BC5E9F91BB7E15600A393DD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Alamofire.framework; + remoteRef = 4BC5E9FB1BB7E15600A393DD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "Alamofire OSX Tests.xctest"; + remoteRef = 4BC5E9FD1BB7E15600A393DD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 4BC5EA041BB7E15600A393DD /* SwiftyJSON.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = SwiftyJSON.framework; - remoteRef = A8A2DBB21A2328F500AF9EFC /* PBXContainerItemProxy */; + remoteRef = 4BC5EA031BB7E15600A393DD /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - A8A2DBB51A2328F500AF9EFC /* SwiftyJSONOSXTests.xctest */ = { + 4BC5EA061BB7E15600A393DD /* SwiftyJSON OSX Tests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; - path = SwiftyJSONOSXTests.xctest; - remoteRef = A8A2DBB41A2328F500AF9EFC /* PBXContainerItemProxy */; + path = "SwiftyJSON OSX Tests.xctest"; + remoteRef = 4BC5EA051BB7E15600A393DD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 4BC5EA081BB7E15600A393DD /* SwiftyJSON.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = SwiftyJSON.framework; + remoteRef = 4BC5EA071BB7E15600A393DD /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; A8AFB75A19D14A5C0070765E /* Alamofire.framework */ = { @@ -356,7 +417,7 @@ A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; - path = AlamofireTests.xctest; + path = "Alamofire iOS Tests.xctest"; remoteRef = A8AFB75B19D14A5C0070765E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -370,7 +431,7 @@ A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; - path = SwiftyJSONTests.xctest; + path = "SwiftyJSON iOS Tests.xctest"; remoteRef = A8AFB76619D14A670070765E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; diff --git a/Alamofire-SwiftyJSON.xcodeproj/project.xcworkspace/xcshareddata/Alamofire-SwiftyJSON.xcscmblueprint b/Alamofire-SwiftyJSON.xcodeproj/project.xcworkspace/xcshareddata/Alamofire-SwiftyJSON.xcscmblueprint new file mode 100644 index 0000000..817d609 --- /dev/null +++ b/Alamofire-SwiftyJSON.xcodeproj/project.xcworkspace/xcshareddata/Alamofire-SwiftyJSON.xcscmblueprint @@ -0,0 +1,37 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "79EA0C4F360E98830418AFAE1A03A39D646B0106", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "67620B5EFA902936DF04070AF595B76AB0333747" : 0, + "C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3" : 0, + "79EA0C4F360E98830418AFAE1A03A39D646B0106" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "91EDE7D1-24DF-4EB3-99E3-20EFE55617CE", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "67620B5EFA902936DF04070AF595B76AB0333747" : "Alamofire-SwiftyJSON\/Alamofire\/", + "C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3" : "Alamofire-SwiftyJSON\/SwiftyJSON\/", + "79EA0C4F360E98830418AFAE1A03A39D646B0106" : "Alamofire-SwiftyJSON\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "Alamofire-SwiftyJSON", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Alamofire-SwiftyJSON.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Alamofire\/Alamofire.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "67620B5EFA902936DF04070AF595B76AB0333747" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/jregnauld\/Alamofire-SwiftyJSON.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "79EA0C4F360E98830418AFAE1A03A39D646B0106" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/SwiftyJSON\/SwiftyJSON.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3" + } + ] +} \ No newline at end of file diff --git a/Source/Alamofire-SwiftyJSON.swift b/Source/Alamofire-SwiftyJSON.swift index ed1e087..2b331a6 100644 --- a/Source/Alamofire-SwiftyJSON.swift +++ b/Source/Alamofire-SwiftyJSON.swift @@ -37,20 +37,23 @@ extension Request { */ public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, ErrorType?) -> Void) -> Self { - return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, result) -> Void in - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { - var responseJSON: JSON - if result.isFailure - { - responseJSON = JSON.null - } else { - responseJSON = SwiftyJSON.JSON(result.value!) - } - dispatch_async(queue ?? dispatch_get_main_queue(), { - completionHandler(self.request!, self.response, responseJSON, result.error) + // With Alamofire 3, completionHandler returns a Response struct instead of request, response, result. + //For more information about Response struct see: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md + return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (response) -> Void in + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { + var responseJSON: JSON + if response.result.isFailure + { + responseJSON = JSON.null + } else { + responseJSON = SwiftyJSON.JSON(response.result.value!) + } + dispatch_async(queue ?? dispatch_get_main_queue(), { + completionHandler(response.request!, response.response, responseJSON, response.result.error) + }) }) }) - }) + } } From 4a3a160e0ff2036f7da4b50cad2a0cd5c465cecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rok=20Gregoric=CC=8C?= Date: Tue, 4 Oct 2016 13:54:28 +0200 Subject: [PATCH 03/11] Added support for Alamofire 4 & SwiftyJSON 3. --- Alamofire-SwiftyJSON.podspec | 6 +- Source/Alamofire-SwiftyJSON.swift | 107 +++++++++++++++++++----------- 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/Alamofire-SwiftyJSON.podspec b/Alamofire-SwiftyJSON.podspec index 15d1c8b..9263517 100644 --- a/Alamofire-SwiftyJSON.podspec +++ b/Alamofire-SwiftyJSON.podspec @@ -8,9 +8,9 @@ Pod::Spec.new do |s| s.requires_arc = true s.osx.deployment_target = "10.9" - s.ios.deployment_target = "8.0" + s.ios.deployment_target = "9.0" s.source = { :git => "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git", :tag => s.version } s.source_files = "Source/*.swift" - s.dependency 'Alamofire', '1.3' - s.dependency 'SwiftyJSON', '2.2.0' + s.dependency 'Alamofire', '~> 4.0' + s.dependency 'SwiftyJSON', '~> 3.0' end diff --git a/Source/Alamofire-SwiftyJSON.swift b/Source/Alamofire-SwiftyJSON.swift index 2b331a6..fcb185a 100644 --- a/Source/Alamofire-SwiftyJSON.swift +++ b/Source/Alamofire-SwiftyJSON.swift @@ -14,47 +14,74 @@ import SwiftyJSON // MARK: - Request for Swift JSON extension Request { - - /** - Adds a handler to be called once the request has finished. - - :param: completionHandler A closure to be executed once the request has finished. The closure takes 4 arguments: the URL request, the URL response, if one was received, the SwiftyJSON enum, if one could be created from the URL response and data, and any error produced while creating the SwiftyJSON enum. - - :returns: The request. - */ - public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, ErrorType?) -> Void) -> Self { - return responseSwiftyJSON(nil, options:NSJSONReadingOptions.AllowFragments, completionHandler:completionHandler) - } - - /** - Adds a handler to be called once the request has finished. - - :param: queue The queue on which the completion handler is dispatched. - :param: options The JSON serialization reading options. `.AllowFragments` by default. - :param: completionHandler A closure to be executed once the request has finished. The closure takes 4 arguments: the URL request, the URL response, if one was received, the SwiftyJSON enum, if one could be created from the URL response and data, and any error produced while creating the SwiftyJSON enum. - - :returns: The request. - */ - public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, ErrorType?) -> Void) -> Self { - - // With Alamofire 3, completionHandler returns a Response struct instead of request, response, result. - //For more information about Response struct see: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md - return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (response) -> Void in - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { - var responseJSON: JSON - if response.result.isFailure - { - responseJSON = JSON.null - } else { - responseJSON = SwiftyJSON.JSON(response.result.value!) - } - dispatch_async(queue ?? dispatch_get_main_queue(), { - completionHandler(response.request!, response.response, responseJSON, response.result.error) - }) - }) - }) - + /// Returns a SwiftyJSON object contained in a result type constructed from the response data using `JSONSerialization` + /// with the specified reading options. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// - parameter response: The response from the server. + /// - parameter data: The data returned from the server. + /// - parameter error: The error already encountered if it exists. + /// + /// - returns: The result data type. + public static func serializeResponseSwiftyJSON( + options: JSONSerialization.ReadingOptions, + response: HTTPURLResponse?, + data: Data?, + error: Error?) + -> Result + { + guard error == nil else { return .failure(error!) } + + if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(JSON.null) } + + guard let validData = data, validData.count > 0 else { + return .failure(AFError.responseSerializationFailed(reason: .inputDataNilOrZeroLength)) + } + + do { + let json = try JSONSerialization.jsonObject(with: validData, options: options) + return .success(JSON(json)) + } catch { + return .failure(AFError.responseSerializationFailed(reason: .jsonSerializationFailed(error: error))) + } } } +extension DataRequest { + /// Creates a response serializer that returns a SwiftyJSON object result type constructed from the response data using + /// `JSONSerialization` with the specified reading options. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// + /// - returns: A JSON object response serializer. + public static func swiftyJSONResponseSerializer( + options: JSONSerialization.ReadingOptions = .allowFragments) + -> DataResponseSerializer + { + return DataResponseSerializer { _, response, data, error in + return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error) + } + } + /// Adds a handler to be called once the request has finished. + /// + /// - parameter options: The JSON serialization reading options. Defaults to `.allowFragments`. + /// - parameter completionHandler: A closure to be executed once the request has finished. + /// + /// - returns: The request. + @discardableResult + public func responseSwiftyJSON( + queue: DispatchQueue? = nil, + options: JSONSerialization.ReadingOptions = .allowFragments, + completionHandler: @escaping (DataResponse) -> Void) + -> Self + { + return response( + queue: queue, + responseSerializer: DataRequest.swiftyJSONResponseSerializer(options: options), + completionHandler: completionHandler + ) + } +} + +private let emptyDataStatusCodes: Set = [204, 205] From d6a4a5e4f55b1fc974c4e3ab702ab1cb1ba73f18 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sun, 19 Feb 2017 22:48:43 +0800 Subject: [PATCH 04/11] Update Alamofire submodule to master --- Alamofire | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alamofire b/Alamofire index ba280a4..fa3c6d0 160000 --- a/Alamofire +++ b/Alamofire @@ -1 +1 @@ -Subproject commit ba280a4fbd591cffb52542ccb6b9897a50604cff +Subproject commit fa3c6d09b603f417c7788adb51ca0cade75b3d67 From 77af21c61ac03003dc9720d145e56fed40e19f18 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sun, 19 Feb 2017 22:49:19 +0800 Subject: [PATCH 05/11] Update SwiftyJSON submodule to master --- SwiftyJSON | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftyJSON b/SwiftyJSON index 3b5d0d4..ae848b2 160000 --- a/SwiftyJSON +++ b/SwiftyJSON @@ -1 +1 @@ -Subproject commit 3b5d0d4e0c19173b1bf0dc823bde25ad870f70c0 +Subproject commit ae848b2910c3e5a0978f973de2ab2aca61e83f66 From f936cbb05aff2638dc28d4bb10dabb9f6aea9ece Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sun, 19 Feb 2017 23:05:35 +0800 Subject: [PATCH 06/11] Update Project settings to recommend settings --- .../project.pbxproj | 96 +++++++++++++++++-- .../xcschemes/AlamofireSwiftyJSON.xcscheme | 13 ++- Source/Info.plist | 2 +- Tests/Info.plist | 2 +- 4 files changed, 98 insertions(+), 15 deletions(-) diff --git a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj index 18d94a8..bce0e24 100644 --- a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj +++ b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj @@ -60,6 +60,34 @@ remoteGlobalIDString = E4D7CCE81B9465A700EE7221; remoteInfo = "SwiftyJSON watchOS"; }; + A81D16431E59E90500C62C5F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 4CF626EF1BA7CB3E0011A099; + remoteInfo = "Alamofire tvOS"; + }; + A81D16451E59E90500C62C5F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 4CF626F81BA7CB3E0011A099; + remoteInfo = "Alamofire tvOS Tests"; + }; + A81D164D1E59E90500C62C5F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 7236B4F61BAC14150020529B; + remoteInfo = "SwiftyJSON tvOS"; + }; + A81D164F1E59E90500C62C5F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A8580F741BCF5C5B00DA927B; + remoteInfo = "SwiftyJSON tvOS Tests"; + }; A8A2DBB61A23290100AF9EFC /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */; @@ -242,10 +270,12 @@ isa = PBXGroup; children = ( A8AFB75A19D14A5C0070765E /* Alamofire.framework */, + A8AFB75C19D14A5C0070765E /* Alamofire iOS Tests.xctest */, 4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */, + 4BC5E9FE1BB7E15600A393DD /* Alamofire macOS Tests.xctest */, + A81D16441E59E90500C62C5F /* Alamofire.framework */, + A81D16461E59E90500C62C5F /* Alamofire tvOS Tests.xctest */, 4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */, - A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */, - 4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */, ); name = Products; sourceTree = ""; @@ -254,10 +284,12 @@ isa = PBXGroup; children = ( A8AFB76519D14A670070765E /* SwiftyJSON.framework */, - A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */, + A8AFB76719D14A670070765E /* SwiftyJSON iOS Tests.xctest */, 4BC5EA041BB7E15600A393DD /* SwiftyJSON.framework */, 4BC5EA061BB7E15600A393DD /* SwiftyJSON OSX Tests.xctest */, 4BC5EA081BB7E15600A393DD /* SwiftyJSON.framework */, + A81D164E1E59E90500C62C5F /* SwiftyJSON.framework */, + A81D16501E59E90500C62C5F /* SwiftyJSON tvOS Tests.xctest */, ); name = Products; sourceTree = ""; @@ -325,14 +357,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0600; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = SwiftJSON; TargetAttributes = { A8AFB70E19D1401D0070765E = { CreatedOnToolsVersion = 6.0.1; + LastSwiftMigration = 0820; }; A8AFB71919D1401D0070765E = { CreatedOnToolsVersion = 6.0.1; + LastSwiftMigration = 0820; }; }; }; @@ -379,10 +413,10 @@ remoteRef = 4BC5E9FB1BB7E15600A393DD /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */ = { + 4BC5E9FE1BB7E15600A393DD /* Alamofire macOS Tests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; - path = "Alamofire OSX Tests.xctest"; + path = "Alamofire macOS Tests.xctest"; remoteRef = 4BC5E9FD1BB7E15600A393DD /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -407,6 +441,34 @@ remoteRef = 4BC5EA071BB7E15600A393DD /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + A81D16441E59E90500C62C5F /* Alamofire.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Alamofire.framework; + remoteRef = A81D16431E59E90500C62C5F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A81D16461E59E90500C62C5F /* Alamofire tvOS Tests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "Alamofire tvOS Tests.xctest"; + remoteRef = A81D16451E59E90500C62C5F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A81D164E1E59E90500C62C5F /* SwiftyJSON.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = SwiftyJSON.framework; + remoteRef = A81D164D1E59E90500C62C5F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A81D16501E59E90500C62C5F /* SwiftyJSON tvOS Tests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "SwiftyJSON tvOS Tests.xctest"; + remoteRef = A81D164F1E59E90500C62C5F /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; A8AFB75A19D14A5C0070765E /* Alamofire.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; @@ -414,7 +476,7 @@ remoteRef = A8AFB75919D14A5C0070765E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */ = { + A8AFB75C19D14A5C0070765E /* Alamofire iOS Tests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = "Alamofire iOS Tests.xctest"; @@ -428,7 +490,7 @@ remoteRef = A8AFB76419D14A670070765E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */ = { + A8AFB76719D14A670070765E /* SwiftyJSON iOS Tests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = "SwiftyJSON iOS Tests.xctest"; @@ -515,16 +577,20 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -561,8 +627,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -571,6 +639,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -580,6 +649,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -590,6 +660,7 @@ A8AFB72319D1401D0070765E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -597,14 +668,17 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; A8AFB72419D1401D0070765E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -612,8 +686,10 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -630,7 +706,9 @@ ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -643,7 +721,9 @@ ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Alamofire-SwiftyJSON.xcodeproj/xcshareddata/xcschemes/AlamofireSwiftyJSON.xcscheme b/Alamofire-SwiftyJSON.xcodeproj/xcshareddata/xcschemes/AlamofireSwiftyJSON.xcscheme index 74e3960..d404f08 100644 --- a/Alamofire-SwiftyJSON.xcodeproj/xcshareddata/xcschemes/AlamofireSwiftyJSON.xcscheme +++ b/Alamofire-SwiftyJSON.xcodeproj/xcshareddata/xcschemes/AlamofireSwiftyJSON.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:Alamofire-SwiftyJSON.xcodeproj"> + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.swiftjson.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Tests/Info.plist b/Tests/Info.plist index 1558953..ba72822 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.swiftjson.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From 746a638bc0efb1f565368011d807db05c84f27b3 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sat, 25 Feb 2017 21:37:46 +0800 Subject: [PATCH 07/11] Fix broken testcase --- Source/Alamofire-SwiftyJSON.swift | 2 +- Tests/Alamofire_SwiftyJSONTests.swift | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/Alamofire-SwiftyJSON.swift b/Source/Alamofire-SwiftyJSON.swift index fcb185a..84806fc 100644 --- a/Source/Alamofire-SwiftyJSON.swift +++ b/Source/Alamofire-SwiftyJSON.swift @@ -59,7 +59,7 @@ extension DataRequest { -> DataResponseSerializer { return DataResponseSerializer { _, response, data, error in - return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error) + return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error) } } diff --git a/Tests/Alamofire_SwiftyJSONTests.swift b/Tests/Alamofire_SwiftyJSONTests.swift index 1869600..43731b0 100644 --- a/Tests/Alamofire_SwiftyJSONTests.swift +++ b/Tests/Alamofire_SwiftyJSONTests.swift @@ -6,7 +6,6 @@ // Copyright (c) 2014年 SwiftJSON. All rights reserved. // -import UIKit import XCTest import Alamofire import SwiftyJSON @@ -14,20 +13,19 @@ import AlamofireSwiftyJSON class Alamofire_SwiftyJSONTests: XCTestCase { - func testJSONResponse() { + func testGETRequestJSONResponse() { let URL = "http://httpbin.org/get" - let expectation = expectationWithDescription("\(URL)") - - Alamofire.request(.GET, URL, parameters: ["foo": "bar"]).responseSwiftyJSON({(request, response, responseJSON, error) in - expectation.fulfill() - XCTAssertNotNil(request, "request should not be nil") - XCTAssertNotNil(response, "response should not be nil") - XCTAssertTrue(error == nil, "result error should be nil") - XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal") - }) - waitForExpectationsWithTimeout(10) { (error) in - XCTAssertNil(error, "\(error)") + let parameters: Parameters = ["foo": "bar"] + let expect = expectation(description: "responseSwiftyJSON method should work") + Alamofire.request(URL, method: .get, parameters: parameters, encoding: URLEncoding.default) + .validate() + .responseSwiftyJSON { response in + XCTAssertNotNil(response.request, "request should not be nil") + XCTAssertNotNil(response.response, "response should not be nil") + XCTAssertNil(response.error, "result error should be nil") + XCTAssertEqual(response.value?["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal") + expect.fulfill() } + waitForExpectations(timeout: 10.0, handler: nil) } - } From 3cf38fc4f09dafa0f697c00244caadeaf1e4be65 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sat, 25 Feb 2017 21:45:26 +0800 Subject: [PATCH 08/11] Add .travis.yml file --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cabba04 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: objective-c +osx_image: xcode8.2 +xcode_sdk: iphonesimulator10.0 +script: +- xcodebuild -project Alamofire-SwiftyJSON.xcodeproj -scheme "AlamofireSwiftyJSON" -destination "platform=iOS Simulator,name=iPhone 6" build-for-testing test | xcpretty \ No newline at end of file From f32be4347159b4464477c56ebfde927f2b13eec5 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sat, 25 Feb 2017 21:54:40 +0800 Subject: [PATCH 09/11] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cabba04..dbf987f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: objective-c osx_image: xcode8.2 xcode_sdk: iphonesimulator10.0 script: -- xcodebuild -project Alamofire-SwiftyJSON.xcodeproj -scheme "AlamofireSwiftyJSON" -destination "platform=iOS Simulator,name=iPhone 6" build-for-testing test | xcpretty \ No newline at end of file +- set -o pipefail && xcodebuild -project Alamofire-SwiftyJSON.xcodeproj -scheme "AlamofireSwiftyJSON" -destination "id=22FA2149-1241-469C-BF6D-462D3837DB72" build-for-testing test | xcpretty From 04c2f40820100225b75dccd235c5cd9d125b63fd Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sat, 25 Feb 2017 22:01:52 +0800 Subject: [PATCH 10/11] Remove custom framework_search_paths to get rid of warning --- Alamofire-SwiftyJSON.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj index bce0e24..a273636 100644 --- a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj +++ b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj @@ -696,10 +696,6 @@ A8AFB72619D1401D0070765E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -715,10 +711,6 @@ A8AFB72719D1401D0070765E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)"; From 3a3d2b0a456b461d917b0436e01373574334f649 Mon Sep 17 00:00:00 2001 From: Zigii Wong Date: Sat, 25 Feb 2017 22:25:04 +0800 Subject: [PATCH 11/11] Fix test issue --- Alamofire-SwiftyJSON.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj index a273636..01387f3 100644 --- a/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj +++ b/Alamofire-SwiftyJSON.xcodeproj/project.pbxproj @@ -168,7 +168,7 @@ }; A8A2DBC21A2329CE00AF9EFC /* Copy Frameworks */ = { isa = PBXCopyFilesBuildPhase; - buildActionMask = 8; + buildActionMask = 12; dstPath = ""; dstSubfolderSpec = 10; files = ( @@ -177,7 +177,7 @@ A8A2DBC51A2329E700AF9EFC /* AlamofireSwiftyJSON.framework in Copy Frameworks */, ); name = "Copy Frameworks"; - runOnlyForDeploymentPostprocessing = 1; + runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */