Skip to content

Commit b6c047d

Browse files
author
Kevin Lefèvre
authored
Merge pull request #70 from snipsco/swift4
Swift 4
2 parents e79a6e6 + 2baf07f commit b6c047d

10 files changed

Lines changed: 66 additions & 36 deletions

File tree

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
4.0.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode8
2+
osx_image: xcode9
33
script:
44
- xcodebuild -workspace Postal.xcworkspace -scheme Postal-iOS -sdk iphonesimulator build
55
- xcodebuild -workspace Postal.xcworkspace -scheme Postal-macOS -sdk macosx build

Postal.xcodeproj/project.pbxproj

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@
577577
isa = PBXProject;
578578
attributes = {
579579
LastSwiftUpdateCheck = 0730;
580-
LastUpgradeCheck = 0820;
580+
LastUpgradeCheck = 0900;
581581
ORGANIZATIONNAME = snips;
582582
TargetAttributes = {
583583
9812C31B1D50959500630D46 = {
@@ -590,7 +590,7 @@
590590
};
591591
98DB00941CEC6983003CAABB = {
592592
CreatedOnToolsVersion = 7.3.1;
593-
LastSwiftMigration = 0800;
593+
LastSwiftMigration = 0900;
594594
};
595595
98DB009E1CEC6983003CAABB = {
596596
CreatedOnToolsVersion = 7.3.1;
@@ -876,14 +876,20 @@
876876
CLANG_CXX_LIBRARY = "libc++";
877877
CLANG_ENABLE_MODULES = YES;
878878
CLANG_ENABLE_OBJC_ARC = YES;
879+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
879880
CLANG_WARN_BOOL_CONVERSION = YES;
881+
CLANG_WARN_COMMA = YES;
880882
CLANG_WARN_CONSTANT_CONVERSION = YES;
881883
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
882884
CLANG_WARN_EMPTY_BODY = YES;
883885
CLANG_WARN_ENUM_CONVERSION = YES;
884886
CLANG_WARN_INFINITE_RECURSION = YES;
885887
CLANG_WARN_INT_CONVERSION = YES;
888+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
889+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
886890
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
891+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
892+
CLANG_WARN_STRICT_PROTOTYPES = YES;
887893
CLANG_WARN_SUSPICIOUS_MOVE = YES;
888894
CLANG_WARN_UNREACHABLE_CODE = YES;
889895
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -927,14 +933,20 @@
927933
CLANG_CXX_LIBRARY = "libc++";
928934
CLANG_ENABLE_MODULES = YES;
929935
CLANG_ENABLE_OBJC_ARC = YES;
936+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
930937
CLANG_WARN_BOOL_CONVERSION = YES;
938+
CLANG_WARN_COMMA = YES;
931939
CLANG_WARN_CONSTANT_CONVERSION = YES;
932940
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
933941
CLANG_WARN_EMPTY_BODY = YES;
934942
CLANG_WARN_ENUM_CONVERSION = YES;
935943
CLANG_WARN_INFINITE_RECURSION = YES;
936944
CLANG_WARN_INT_CONVERSION = YES;
945+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
946+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
937947
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
948+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
949+
CLANG_WARN_STRICT_PROTOTYPES = YES;
938950
CLANG_WARN_SUSPICIOUS_MOVE = YES;
939951
CLANG_WARN_UNREACHABLE_CODE = YES;
940952
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -972,6 +984,7 @@
972984
buildSettings = {
973985
APPLICATION_EXTENSION_API_ONLY = YES;
974986
CLANG_ENABLE_MODULES = YES;
987+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
975988
DEFINES_MODULE = YES;
976989
DYLIB_COMPATIBILITY_VERSION = 1;
977990
DYLIB_CURRENT_VERSION = 1;
@@ -995,7 +1008,7 @@
9951008
SKIP_INSTALL = YES;
9961009
SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/dependencies/build/ios/include";
9971010
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
998-
SWIFT_VERSION = 3.0;
1011+
SWIFT_VERSION = 4.0;
9991012
};
10001013
name = Debug;
10011014
};
@@ -1004,6 +1017,7 @@
10041017
buildSettings = {
10051018
APPLICATION_EXTENSION_API_ONLY = YES;
10061019
CLANG_ENABLE_MODULES = YES;
1020+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
10071021
DEFINES_MODULE = YES;
10081022
DYLIB_COMPATIBILITY_VERSION = 1;
10091023
DYLIB_CURRENT_VERSION = 1;
@@ -1024,7 +1038,7 @@
10241038
SKIP_INSTALL = YES;
10251039
SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/dependencies/build/ios/include";
10261040
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1027-
SWIFT_VERSION = 3.0;
1041+
SWIFT_VERSION = 4.0;
10281042
};
10291043
name = Release;
10301044
};

Postal.xcodeproj/xcshareddata/xcschemes/Postal-iOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"
@@ -40,6 +40,7 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
language = ""
4344
shouldUseLaunchSchemeArgsEnv = "YES">
4445
<Testables>
4546
<TestableReference
@@ -69,6 +70,7 @@
6970
buildConfiguration = "Debug"
7071
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7172
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73+
language = ""
7274
launchStyle = "0"
7375
useCustomWorkingDirectory = "NO"
7476
ignoresPersistentStateOnLaunch = "NO"

Postal.xcodeproj/xcshareddata/xcschemes/Postal-macOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"
@@ -40,6 +40,7 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
language = ""
4344
shouldUseLaunchSchemeArgsEnv = "YES">
4445
<Testables>
4546
<TestableReference
@@ -69,6 +70,7 @@
6970
buildConfiguration = "Debug"
7071
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7172
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73+
language = ""
7274
launchStyle = "0"
7375
useCustomWorkingDirectory = "NO"
7476
ignoresPersistentStateOnLaunch = "NO"

Postal/IMAPSession+Fetch.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ extension IndexSet {
124124
var unreleasedMailimapSet: UnsafeMutablePointer<mailimap_set> {
125125
let result: UnsafeMutablePointer<mailimap_set> = mailimap_set_new_empty()
126126

127-
rangeView.forEach { (range) in
128-
let safeFirst = UInt32(truncatingBitPattern: range.startIndex)
129-
let safeLast = UInt32(truncatingBitPattern: range.upperBound - 1)
127+
rangeView.forEach { range in
128+
let safeFirst = UInt32(truncatingIfNeeded: range.startIndex)
129+
let safeLast = UInt32(truncatingIfNeeded: range.upperBound - 1)
130130

131131
mailimap_set_add_interval(result, safeFirst, safeLast)
132132
}

Postal/IMAPSession.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ final class IMAPSession {
7373
self.configuration = configuration
7474

7575
// We need to give the progress callbacks to stream values to end user.
76-
let _bodyProgress: Progress = { _ in }
77-
let _itemsProgress: Progress = { _ in }
76+
let _bodyProgress: Progress = { _,_,_ in }
77+
let _itemsProgress: Progress = { _,_,_ in }
7878
mailimap_set_progress_callback(imap, _bodyProgress, _itemsProgress, nil)
7979
}
8080

Postal/Postal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public extension Postal {
268268

269269
private extension Postal {
270270

271-
func doAsync<T, E: Error>(_ f: @escaping () throws -> T, completion: @escaping (Result<T, E>) -> Void) {
271+
func doAsync<T, E>(_ f: @escaping () throws -> T, completion: @escaping (Result<T, E>) -> Void) {
272272
queue.addOperation {
273273
let result = Result<T, E>(attempt: f)
274274
DispatchQueue.main.async {

PostalDemo/PostalDemo.xcodeproj/project.pbxproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@
138138
isa = PBXProject;
139139
attributes = {
140140
LastSwiftUpdateCheck = 0730;
141-
LastUpgradeCheck = 0800;
141+
LastUpgradeCheck = 0900;
142142
ORGANIZATIONNAME = Snips;
143143
TargetAttributes = {
144144
F7DE80071CF363110031E26A = {
145145
CreatedOnToolsVersion = 7.3.1;
146-
LastSwiftMigration = 0800;
146+
LastSwiftMigration = 0900;
147147
};
148148
};
149149
};
@@ -222,14 +222,20 @@
222222
CLANG_CXX_LIBRARY = "libc++";
223223
CLANG_ENABLE_MODULES = YES;
224224
CLANG_ENABLE_OBJC_ARC = YES;
225+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
225226
CLANG_WARN_BOOL_CONVERSION = YES;
227+
CLANG_WARN_COMMA = YES;
226228
CLANG_WARN_CONSTANT_CONVERSION = YES;
227229
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
228230
CLANG_WARN_EMPTY_BODY = YES;
229231
CLANG_WARN_ENUM_CONVERSION = YES;
230232
CLANG_WARN_INFINITE_RECURSION = YES;
231233
CLANG_WARN_INT_CONVERSION = YES;
234+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
235+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
232236
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
237+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
238+
CLANG_WARN_STRICT_PROTOTYPES = YES;
233239
CLANG_WARN_SUSPICIOUS_MOVE = YES;
234240
CLANG_WARN_UNREACHABLE_CODE = YES;
235241
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -270,14 +276,20 @@
270276
CLANG_CXX_LIBRARY = "libc++";
271277
CLANG_ENABLE_MODULES = YES;
272278
CLANG_ENABLE_OBJC_ARC = YES;
279+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
273280
CLANG_WARN_BOOL_CONVERSION = YES;
281+
CLANG_WARN_COMMA = YES;
274282
CLANG_WARN_CONSTANT_CONVERSION = YES;
275283
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
276284
CLANG_WARN_EMPTY_BODY = YES;
277285
CLANG_WARN_ENUM_CONVERSION = YES;
278286
CLANG_WARN_INFINITE_RECURSION = YES;
279287
CLANG_WARN_INT_CONVERSION = YES;
288+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
289+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
280290
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
291+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
292+
CLANG_WARN_STRICT_PROTOTYPES = YES;
281293
CLANG_WARN_SUSPICIOUS_MOVE = YES;
282294
CLANG_WARN_UNREACHABLE_CODE = YES;
283295
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -310,7 +322,7 @@
310322
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
311323
PRODUCT_BUNDLE_IDENTIFIER = ai.snips.PostalDemo;
312324
PRODUCT_NAME = "$(TARGET_NAME)";
313-
SWIFT_VERSION = 3.0;
325+
SWIFT_VERSION = 4.0;
314326
};
315327
name = Debug;
316328
};
@@ -323,7 +335,7 @@
323335
PRODUCT_BUNDLE_IDENTIFIER = ai.snips.PostalDemo;
324336
PRODUCT_NAME = "$(TARGET_NAME)";
325337
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
326-
SWIFT_VERSION = 3.0;
338+
SWIFT_VERSION = 4.0;
327339
};
328340
name = Release;
329341
};

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
[![Build Status](https://travis-ci.org/snipsco/Postal.svg?branch=master)](https://travis-ci.org/snipsco/Postal)
55
[![Carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
6-
[![Pods](https://img.shields.io/badge/Pods-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/)
7-
[![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg?style=flat)](https://swift.org/)
6+
[![Pods](https://img.shields.io/badge/Pods-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/)
7+
[![Swift 4.0.x](https://img.shields.io/badge/Swift-4.0.x-orange.svg?style=flat)](https://swift.org/)
88
![Platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS-lightgrey.svg?style=flat)
99

1010
Postal is a swift framework providing simple access to common email providers.
@@ -16,12 +16,12 @@ Postal is a swift framework providing simple access to common email providers.
1616
```swift
1717
let postal = Postal(configuration: .icloud(login: "myemail@icloud.com", password: "mypassword"))
1818
postal.connect { result in
19-
switch result {
20-
case .success:
21-
print("success")
22-
case .failure(let error):
23-
print("error: \(error)")
24-
}
19+
switch result {
20+
case .success:
21+
print("success")
22+
case .failure(let error):
23+
print("error: \(error)")
24+
}
2525
}
2626
```
2727

@@ -30,12 +30,12 @@ postal.connect { result in
3030
```swift
3131
let filter = .subject(value: "Foobar") && .from(value: "foo@bar.com")
3232
postal.search("INBOX", filter: filter) { result in
33-
switch result {
34-
case .success(let indexes):
35-
print("success: \(indexes)")
36-
case .failure(let error):
37-
print("error: \(error)")
38-
}
33+
switch result {
34+
case .success(let indexes):
35+
print("success: \(indexes)")
36+
case .failure(let error):
37+
print("error: \(error)")
38+
}
3939
}
4040
```
4141

@@ -44,11 +44,11 @@ postal.search("INBOX", filter: filter) { result in
4444
```swift
4545
let indexset = NSIndexSet(index: 42)
4646
postal.fetchMessages("INBOX", uids: indexset, flags: [ .headers ], onMessage: { email in
47-
print("new email received: \(email)")
47+
print("new email received: \(email)")
4848
}, onComplete: error in
49-
if error = error {
50-
print("an error occured: \(error)")
51-
}
49+
if error = error {
50+
print("an error occured: \(error)")
51+
}
5252
}
5353
```
5454

0 commit comments

Comments
 (0)