Merge pull request #50 from SwiftyJSON/alamofire4

Alamofire 4.0.0 + Swift 3.0
This commit is contained in:
Zigii Wong
2017-02-25 22:33:58 +08:00
committed by GitHub
11 changed files with 300 additions and 94 deletions

5
.travis.yml Normal file
View File

@@ -0,0 +1,5 @@
language: objective-c
osx_image: xcode8.2
xcode_sdk: iphonesimulator10.0
script:
- set -o pipefail && xcodebuild -project Alamofire-SwiftyJSON.xcodeproj -scheme "AlamofireSwiftyJSON" -destination "id=22FA2149-1241-469C-BF6D-462D3837DB72" build-for-testing test | xcpretty

View File

@@ -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

View File

@@ -18,19 +18,75 @@
/* 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";
};
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;
@@ -112,7 +168,7 @@
};
A8A2DBC21A2329CE00AF9EFC /* Copy Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
buildActionMask = 12;
dstPath = "";
dstSubfolderSpec = 10;
files = (
@@ -121,7 +177,7 @@
A8A2DBC51A2329E700AF9EFC /* AlamofireSwiftyJSON.framework in Copy Frameworks */,
);
name = "Copy Frameworks";
runOnlyForDeploymentPostprocessing = 1;
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
@@ -214,7 +270,12 @@
isa = PBXGroup;
children = (
A8AFB75A19D14A5C0070765E /* Alamofire.framework */,
A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */,
A8AFB75C19D14A5C0070765E /* Alamofire iOS Tests.xctest */,
4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */,
4BC5E9FE1BB7E15600A393DD /* Alamofire macOS Tests.xctest */,
A81D16441E59E90500C62C5F /* Alamofire.framework */,
A81D16461E59E90500C62C5F /* Alamofire tvOS Tests.xctest */,
4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */,
);
name = Products;
sourceTree = "<group>";
@@ -223,9 +284,12 @@
isa = PBXGroup;
children = (
A8AFB76519D14A670070765E /* SwiftyJSON.framework */,
A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */,
A8A2DBB31A2328F500AF9EFC /* SwiftyJSON.framework */,
A8A2DBB51A2328F500AF9EFC /* SwiftyJSONOSXTests.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 = "<group>";
@@ -292,14 +356,17 @@
A8AFB70619D1401D0070765E /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = SwiftJSON;
TargetAttributes = {
A8AFB70E19D1401D0070765E = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0820;
};
A8AFB71919D1401D0070765E = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0820;
};
};
};
@@ -332,18 +399,74 @@
/* 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 macOS Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = "Alamofire macOS 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;
};
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 */ = {
@@ -353,10 +476,10 @@
remoteRef = A8AFB75919D14A5C0070765E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */ = {
A8AFB75C19D14A5C0070765E /* Alamofire iOS Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = AlamofireTests.xctest;
path = "Alamofire iOS Tests.xctest";
remoteRef = A8AFB75B19D14A5C0070765E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
@@ -367,10 +490,10 @@
remoteRef = A8AFB76419D14A670070765E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */ = {
A8AFB76719D14A670070765E /* SwiftyJSON iOS Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = SwiftyJSONTests.xctest;
path = "SwiftyJSON iOS Tests.xctest";
remoteRef = A8AFB76619D14A670070765E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
@@ -454,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",
@@ -500,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";
@@ -510,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;
@@ -519,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";
@@ -529,6 +660,7 @@
A8AFB72319D1401D0070765E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -536,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;
@@ -551,38 +686,36 @@
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;
};
A8AFB72619D1401D0070765E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(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)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
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)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};

View File

@@ -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"
}
]
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
@@ -62,15 +62,18 @@
ReferencedContainer = "container:Alamofire-SwiftyJSON.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
@@ -85,10 +88,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference

View File

@@ -14,44 +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 {
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)
})
})
})
/// 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<JSON>
{
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<JSON>
{
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<JSON>) -> Void)
-> Self
{
return response(
queue: queue,
responseSerializer: DataRequest.swiftyJSONResponseSerializer(options: options),
completionHandler: completionHandler
)
}
}
private let emptyDataStatusCodes: Set<Int> = [204, 205]

View File

@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@@ -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)
}
}

View File

@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.swiftjson.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>