Skip to content

Commit 9f9ef35

Browse files
committed
Swift 4.1 and Xcode 9.3 support - v4.1.0
1 parent 0c3ba3d commit 9f9ef35

20 files changed

+52
-42
lines changed

.swiftlint.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ disabled_rules:
77
- missing_docs
88
- conditional_binding_cascade
99
- force_unwrapping
10+
- identifier_name
1011
opt_in_rules:
1112
- empty_count
1213
- missing_docs

Arrow.framework.zip

-64 KB
Binary file not shown.

Arrow.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Arrow'
3-
s.version = "4.0.0"
3+
s.version = "4.1.0"
44
s.summary = "Elegant JSON Parsing in Swift"
55
s.homepage = "https://github.com/freshOS/Arrow"
66
s.license = { :type => "MIT", :file => "LICENSE" }

Arrow.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
attributes = {
269269
LastSwiftMigration = 0700;
270270
LastSwiftUpdateCheck = 0730;
271-
LastUpgradeCheck = 0900;
271+
LastUpgradeCheck = 0930;
272272
ORGANIZATIONNAME = "Sacha Durand Saint Omer";
273273
TargetAttributes = {
274274
99C292E61B24AD5E0008C32B = {
@@ -408,12 +408,14 @@
408408
CLANG_WARN_BOOL_CONVERSION = YES;
409409
CLANG_WARN_COMMA = YES;
410410
CLANG_WARN_CONSTANT_CONVERSION = YES;
411+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
411412
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
412413
CLANG_WARN_EMPTY_BODY = YES;
413414
CLANG_WARN_ENUM_CONVERSION = YES;
414415
CLANG_WARN_INFINITE_RECURSION = YES;
415416
CLANG_WARN_INT_CONVERSION = YES;
416417
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
418+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
417419
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
418420
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
419421
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -463,12 +465,14 @@
463465
CLANG_WARN_BOOL_CONVERSION = YES;
464466
CLANG_WARN_COMMA = YES;
465467
CLANG_WARN_CONSTANT_CONVERSION = YES;
468+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
466469
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
467470
CLANG_WARN_EMPTY_BODY = YES;
468471
CLANG_WARN_ENUM_CONVERSION = YES;
469472
CLANG_WARN_INFINITE_RECURSION = YES;
470473
CLANG_WARN_INT_CONVERSION = YES;
471474
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
475+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
472476
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
473477
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
474478
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;

Arrow.xcodeproj/xcshareddata/xcschemes/Arrow.xcscheme

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0930"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
<TestableReference
@@ -56,7 +55,6 @@
5655
buildConfiguration = "Debug"
5756
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5857
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6058
launchStyle = "0"
6159
useCustomWorkingDirectory = "NO"
6260
ignoresPersistentStateOnLaunch = "NO"

ArrowTests/ArrayTests.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct ArrayContainer {
2121
var optionalWeekdays: [WeekDay]?
2222
}
2323

24-
extension ArrayContainer:ArrowParsable {
24+
extension ArrayContainer: ArrowParsable {
2525

2626
mutating func deserialize(_ json: JSON) {
2727
phoneNumbers <-- json["phoneNumbers"]
@@ -58,7 +58,7 @@ class ArrayTests: XCTestCase {
5858
XCTAssertEqual(arrayContainer.phoneNumbers[1].number, "0908070656")
5959
XCTAssertEqual(arrayContainer.phoneNumbers[2].number, "0916570656")
6060
} else {
61-
XCTFail()
61+
XCTFail("Parsing ArrayOf Custom Models Fails")
6262
}
6363
}
6464

@@ -81,7 +81,7 @@ class ArrayTests: XCTestCase {
8181
XCTAssertEqual(arrayContainer.strings[1], "two")
8282
XCTAssertEqual(arrayContainer.strings[2], "three")
8383
} else {
84-
XCTFail()
84+
XCTFail("Parsing an array of strings fails")
8585
}
8686
}
8787

@@ -92,7 +92,7 @@ class ArrayTests: XCTestCase {
9292
XCTAssertEqual(arrayContainer.ints[1], 2)
9393
XCTAssertEqual(arrayContainer.ints[2], 3)
9494
} else {
95-
XCTFail()
95+
XCTFail("Parsing an array of ints fails")
9696
}
9797
}
9898

@@ -103,7 +103,7 @@ class ArrayTests: XCTestCase {
103103
XCTAssertEqual(arrayContainer.bools[1], false)
104104
XCTAssertEqual(arrayContainer.bools[2], true)
105105
} else {
106-
XCTFail()
106+
XCTFail("Parsing an array of bools fails")
107107
}
108108
}
109109

@@ -122,7 +122,7 @@ class ArrayTests: XCTestCase {
122122
XCTAssertEqual(arrayContainer.weekdays[1], WeekDay.wednesday)
123123
XCTAssertEqual(arrayContainer.weekdays[2], WeekDay.friday)
124124
} else {
125-
XCTFail()
125+
XCTFail("Parsing an array of enums fails")
126126
}
127127
}
128128

@@ -133,7 +133,7 @@ class ArrayTests: XCTestCase {
133133
XCTAssertEqual(arrayContainer.optionalWeekdays?[1], WeekDay.wednesday)
134134
XCTAssertEqual(arrayContainer.optionalWeekdays?[2], WeekDay.friday)
135135
} else {
136-
XCTFail()
136+
XCTFail("Parsing an array of optional enums fails")
137137
}
138138
}
139139
}

ArrowTests/DateTests.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ class DateTests: XCTestCase {
2525
let df = DateFormatter()
2626
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
2727
if let date = df.date(from: "2013-06-07T16:38:40+02:00") {
28-
XCTAssertEqualWithAccuracy(date.timeIntervalSinceReferenceDate, dateContainer.createdAt
28+
XCTAssertEqual(date.timeIntervalSinceReferenceDate, dateContainer.createdAt
2929
.timeIntervalSinceReferenceDate, accuracy: 0.1)
3030
} else {
31-
XCTFail()
31+
XCTFail("Parsing a date fails")
3232
}
3333
}
3434

3535
func testParsingOptionalDate() {
3636
let timestamp: TimeInterval = 392308720
3737
if let d = dateContainer.optionalDate?.timeIntervalSinceReferenceDate {
38-
XCTAssertEqualWithAccuracy(timestamp, d, accuracy: 0.1)
38+
XCTAssertEqual(timestamp, d, accuracy: 0.1)
3939
} else {
40-
XCTFail()
40+
XCTFail("Parsing an Optional Date fails")
4141
}
4242
}
4343

@@ -50,7 +50,7 @@ class DateTests: XCTestCase {
5050
aDate <-- json["created_at"]?.dateFormatter(df)
5151
XCTAssertEqual(aDate, df.date(from: "2013-06-07T16:38:40+02:00"))
5252
} else {
53-
XCTFail()
53+
XCTFail("Using a custom date Parser fails")
5454
}
5555
}
5656

@@ -63,7 +63,7 @@ class DateTests: XCTestCase {
6363
aDate <-- json["created_at"]
6464
XCTAssertEqual(aDate, df.date(from: "2013-06-07T16:38:40+02:00"))
6565
} else {
66-
XCTFail()
66+
XCTFail("Using a global date parser fails")
6767
}
6868

6969
Arrow.setDateFormatter(nil)

ArrowTests/NativeTypesTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func jsonForName(_ name: String) -> JSON? {
4848
let json = try? JSONSerialization
4949
.jsonObject(with: jsonData,
5050
options: .mutableContainers) as? NSDictionary,
51-
let dic = json as? [String : Any] {
51+
let dic = json as? [String: Any] {
5252
return JSON(dic)
5353
}
5454
return nil

ArrowTests/StringCoercionTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct CoercionContainer {
1515
var cgfloatString: CGFloat = 0.0
1616
}
1717

18-
extension CoercionContainer:ArrowParsable {
18+
extension CoercionContainer: ArrowParsable {
1919

2020
mutating func deserialize(_ json: JSON) {
2121
cgfloatString <-- json["floatString"]

ArrowTests/mapping/CustomModelContainer+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension CustomModelContainer:ArrowParsable {
11+
extension CustomModelContainer: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
stats <-- json["stats"]

ArrowTests/mapping/DateContainer+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension DateContainer:ArrowParsable {
11+
extension DateContainer: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
createdAt <-- json["created_at"]?.dateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ")

ArrowTests/mapping/EnumContainer+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension EnumContainer:ArrowParsable {
11+
extension EnumContainer: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
weekday <-- json["weekdayInt"]

ArrowTests/mapping/Profile+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension Profile:ArrowParsable {
11+
extension Profile: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
identifier <-- json["id"]

ArrowTests/mapping/Stats+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension Stats:ArrowParsable {
11+
extension Stats: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
numberOfFriends <-- json["numberOfFriends"]

ArrowTests/mapping/StringContainer+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension StringContainer:ArrowParsable {
11+
extension StringContainer: ArrowParsable {
1212
mutating func deserialize(_ json: JSON) {
1313
name <-- json["name"]
1414
optionalName = nil

ArrowTests/mapping/URLContainer+JSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Arrow
1010

11-
extension URLContainer:ArrowParsable {
11+
extension URLContainer: ArrowParsable {
1212

1313
mutating func deserialize(_ json: JSON) {
1414
link <-- json["link"]

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Build Status](https://www.bitrise.io/app/ffd8fe5df34624ff.svg?token=IahWn-RB5hTWzvBbcIktsQ)](https://www.bitrise.io/app/ffd8fe5df34624ff)
1010
[![codebeat badge](https://codebeat.co/badges/f037ac0c-b3d9-4132-9fca-64150a908113)](https://codebeat.co/projects/github-com-freshos-arrow)
1111
[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/freshOS/Arrow/blob/master/LICENSE)
12-
[![Release version](https://img.shields.io/badge/release-4.0-blue.svg)]()
12+
![Release version](https://img.shields.io/github/release/freshos/then.svg)
1313

1414
[Reason](#reason) - [Example](#example) - [Installation](#installation)
1515

@@ -239,6 +239,7 @@ if let collection = json.collection {
239239
- Swift 2 -> version [**2.0.3**](https://github.com/freshOS/Arrow/releases/tag/2.0.3)
240240
- Swift 3 -> version [**3.0.5**](https://github.com/freshOS/Arrow/releases/tag/3.0.5)
241241
- Swift 4 -> version [**4.0.0**](https://github.com/freshOS/Arrow/releases/tag/4.0.0)
242+
- Swift 4.1 -> version [**4.1.0**](https://github.com/freshOS/Arrow/releases/tag/4.1.0)
242243

243244
## Acknoledgments
244245
This wouldn't exist without [YannickDot](https://github.com/YannickDot), [Damien-nd](https://github.com/damien-nd) and [maxkonovalov](https://github.com/maxkonovalov)
@@ -249,7 +250,7 @@ This wouldn't exist without [YannickDot](https://github.com/YannickDot), [Damien
249250

250251

251252
### Backers
252-
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)
253+
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)
253254

254255
<a href="https://opencollective.com/freshos/backer/0/website" target="_blank"><img src="https://opencollective.com/freshos/backer/0/avatar.svg"></a>
255256
<a href="https://opencollective.com/freshos/backer/1/website" target="_blank"><img src="https://opencollective.com/freshos/backer/1/avatar.svg"></a>
@@ -283,7 +284,7 @@ Like the project? Offer coffee or support us with a monthly donation and help us
283284
<a href="https://opencollective.com/freshos/backer/29/website" target="_blank"><img src="https://opencollective.com/freshos/backer/29/avatar.svg"></a>
284285

285286
### Sponsors
286-
Become a sponsor and get your logo on our README on Github with a link to your site :)
287+
Become a sponsor and get your logo on our README on Github with a link to your site :)
287288

288289
<a href="https://opencollective.com/freshos/sponsor/0/website" target="_blank"><img src="https://opencollective.com/freshos/sponsor/0/avatar.svg"></a>
289290
<a href="https://opencollective.com/freshos/sponsor/1/website" target="_blank"><img src="https://opencollective.com/freshos/sponsor/1/avatar.svg"></a>

Source/Arrow.swift

+13-7
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public func <-- <T: RawRepresentable>(left: inout T, right: JSON?) {
105105
/// Parses optional enums.
106106
public func <-- <T: RawRepresentable>(left: inout T?, right: JSON?) {
107107
var temp: T.RawValue? = nil
108-
parseType(&temp, right:right)
108+
parseType(&temp, right: right)
109109
if let t = temp, let e = T.init(rawValue: t) {
110110
left = e
111111
}
@@ -119,7 +119,7 @@ public func <-- <T: RawRepresentable>(left: inout [T], right: JSON?) {
119119
/// Parses Optional Array of enums.
120120
public func <-- <T: RawRepresentable>(left: inout [T]?, right: JSON?) {
121121
if let array = right?.data as? [T.RawValue] {
122-
left = array.map { T.init(rawValue: $0) }.flatMap {$0}
122+
left = array.map { T.init(rawValue: $0) }.compactMap {$0}
123123
}
124124
}
125125

@@ -139,7 +139,7 @@ public func <-- <T: ArrowParsable>(left: inout T?, right: JSON?) {
139139

140140
/// Parses arrays of user defined custom types.
141141
public func <-- <T: ArrowParsable>(left: inout [T], right: JSON?) {
142-
setLeftIfIsResultNonNil(left:&left, right:right, function: <--)
142+
setLeftIfIsResultNonNil(left: &left, right: right, function: <--)
143143
}
144144

145145
/// Parses optional arrays of user defined custom types.
@@ -223,20 +223,20 @@ public func <-- (left: inout URL?, right: JSON?) {
223223
str <-- right
224224
let set = CharacterSet.urlQueryAllowed
225225
if let escapedStr = str.addingPercentEncoding(withAllowedCharacters: set),
226-
let url = URL(string:escapedStr) {
226+
let url = URL(string: escapedStr) {
227227
left = url
228228
}
229229
}
230230

231231
/// Parses arrays of plain swift types.
232232
public func <-- <T>(left: inout [T], right: JSON?) {
233-
setLeftIfIsResultNonNil(left:&left, right:right, function: <--)
233+
setLeftIfIsResultNonNil(left: &left, right: right, function: <--)
234234
}
235235

236236
/// Parses optional arrays of plain swift types.
237237
public func <-- <T>(left: inout [T]?, right: JSON?) {
238238
if let a = right?.data as? [Any] {
239-
let tmp: [T] = a.flatMap { var t: T?; parseType(&t, right: JSON($0)); return t }
239+
let tmp: [T] = a.compactMap { var t: T?; parseType(&t, right: JSON($0)); return t }
240240
if tmp.count == a.count {
241241
left = tmp
242242
}
@@ -269,7 +269,13 @@ func parseType<T>(_ left: inout T?, right: JSON?) {
269269
if let v: T = right?.data as? T {
270270
left = v
271271
} else if let s = right?.data as? String {
272-
parseString(&left, string:s)
272+
parseString(&left, string: s)
273+
} else if T.self == Float.self {
274+
// Sepcial case for Float that
275+
// no longer works out of the box in Swift 4.1
276+
if let v = right?.data as? Double, let l = Float(v) as? T {
277+
left = l
278+
}
273279
}
274280
}
275281

Source/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>4.0.0</string>
18+
<string>4.1.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)