Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 11, Swift 5.1 Alamofire 5.0.0-rc.2, SwiftyJSON 5.0.0 #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ DerivedData
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
Pods/
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: objective-c
osx_image: xcode9
xcode_sdk: iphonesimulator10.0
language: swift
osx_image: xcode11
xcode_sdk: iphonesimulator13.0
env:
- PLATFORM="ios" SCHEME="AlamofireSwiftyJSON" DESTINATION="platform=iOS Simulator,name=iPhone SE,OS=10.0"
- PLATFORM="ios" SCHEME="AlamofireSwiftyJSON" DESTINATION="platform=iOS Simulator,name=iPhone SE,OS=13.0"
script:
- set -o pipefail && xcodebuild -project Alamofire-SwiftyJSON.xcodeproj -scheme $SCHEME -destination "$DESTINATION" build-for-testing test | xcpretty
1 change: 0 additions & 1 deletion Alamofire
Submodule Alamofire deleted from 7fe7b9
11 changes: 6 additions & 5 deletions Alamofire-SwiftyJSON.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Pod::Spec.new do |s|
s.name = "Alamofire-SwiftyJSON"
s.version = "3.0.0"
s.summary = "Alamofire extension for serialize NSData to SwiftyJSON "
s.version = "4.0.0"
s.summary = "Alamofire extension for serialize Data to SwiftyJSON"
s.homepage = "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON"
s.license = { :type => "MIT" }
s.authors = { "tangplin" => "[email protected]" }


s.swift_version = '5.1'
s.requires_arc = true
s.osx.deployment_target = "10.11"
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', '~> 4.5'
s.dependency 'SwiftyJSON', '~> 4.0.0'
s.dependency 'Alamofire', '~> 5.0.0-rc.2'
s.dependency 'SwiftyJSON', '~> 5.0.0'
end
418 changes: 116 additions & 302 deletions Alamofire-SwiftyJSON.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,8 +40,16 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A8AFB70E19D1401D0070765E"
BuildableName = "AlamofireSwiftyJSON.framework"
BlueprintName = "AlamofireSwiftyJSON"
ReferencedContainer = "container:Alamofire-SwiftyJSON.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -54,23 +62,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A8AFB70E19D1401D0070765E"
BuildableName = "AlamofireSwiftyJSON.framework"
BlueprintName = "AlamofireSwiftyJSON"
ReferencedContainer = "container:Alamofire-SwiftyJSON.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -86,8 +82,6 @@
ReferencedContainer = "container:Alamofire-SwiftyJSON.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
10 changes: 10 additions & 0 deletions Alamofire-SwiftyJSON.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'AlamofireSwiftyJSON' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

pod 'Alamofire'
pod 'SwiftyJSON'

target 'AlamofireSwiftyJSONTests' do
inherit! :search_paths
# Pods for testing
end

end
20 changes: 20 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PODS:
- Alamofire (4.9.0)
- SwiftyJSON (5.0.0)

DEPENDENCIES:
- Alamofire
- SwiftyJSON

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Alamofire
- SwiftyJSON

SPEC CHECKSUMS:
Alamofire: afc3e7c6db61476cb45cdd23fed06bad03bbc321
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7

PODFILE CHECKSUM: a1602366b4aa23d5adf317c2a7ddeb7bd52d20bc

COCOAPODS: 1.7.5
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ An extension to make serializing [Alamofire](https://github.com/Alamofire/Alamof

⚠️ **To use with Swift 4.x please ensure you are using >= `3.0.0`** ⚠️

⚠️ **To use with Swift 5.x please ensure you are using >= `4.0.0`** ⚠️


## Swift version

Alamofire-SwiftyJSON | Swift version | Alamofire | SwiftyJSON
------------- | --------------| ----------| ----------
2.x | Swift 3.x | 4.x | 3.x
3.x | Swift 4.x | 4.5.x | 4.x
4.x | Swift 5.x | 5.x | 4.x

## Requirements

Expand Down Expand Up @@ -40,10 +44,10 @@ import Alamofire_SwiftyJSON

```swift
Alamofire.request(URL, method: .get, parameters: parameters, encoding: URLEncoding.default)
.responseSwiftyJSON { dataResponse in
print(dataResponse.request)
print(dataResponse.response)
print(dataResponse.error)
print(dataResponse.value)
})
.responseSwiftyJSON { dataResponse in
print(dataResponse.request)
print(dataResponse.response)
print(dataResponse.error)
print(dataResponse.value)
})
```
32 changes: 15 additions & 17 deletions Source/Alamofire-SwiftyJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
//

import Foundation

import Alamofire
import SwiftyJSON

// MARK: - Request for Swift JSON
private let emptyDataStatusCodes: Set<Int> = [204, 205]

extension Request {
/// Returns a SwiftyJSON object contained in a result type constructed from the response data using `JSONSerialization`
Expand All @@ -27,12 +26,15 @@ extension Request {
options: JSONSerialization.ReadingOptions,
response: HTTPURLResponse?,
data: Data?,
error: Error?)
-> Result<JSON>
{
guard error == nil else { return .failure(error!) }
error: Error?
) -> Result<JSON> {
if let error = error {
return .failure(error)
}

if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(JSON.null) }
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))
Expand All @@ -55,11 +57,10 @@ extension DataRequest {
///
/// - returns: A JSON object response serializer.
public static func swiftyJSONResponseSerializer(
options: JSONSerialization.ReadingOptions = .allowFragments)
-> DataResponseSerializer<JSON>
{
options: JSONSerialization.ReadingOptions = .allowFragments
) -> DataResponseSerializer<JSON> {
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)
}
}

Expand All @@ -73,15 +74,12 @@ extension DataRequest {
public func responseSwiftyJSON(
queue: DispatchQueue? = nil,
options: JSONSerialization.ReadingOptions = .allowFragments,
completionHandler: @escaping (DataResponse<JSON>) -> Void)
-> Self
{
return response(
completionHandler: @escaping (DataResponse<JSON>) -> Void
) -> Self {
return self.response(
queue: queue,
responseSerializer: DataRequest.swiftyJSONResponseSerializer(options: options),
completionHandler: completionHandler
)
}
}

private let emptyDataStatusCodes: Set<Int> = [204, 205]
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 0 additions & 1 deletion SwiftyJSON
Submodule SwiftyJSON deleted from 6b9f11