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

Swift 4.0 Support #64

Merged
merged 8 commits into from Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
@@ -1,3 +1,3 @@
[submodule "Vendor/xctoolchain"]
path = Vendor/xctoolchain
url = https://github.com/ParsePlatform/xctoolchain.git
url = https://github.com/nlutsenko/xctoolchain.git
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
3.0
4.0
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ branches:
- master
language: objective-c
os: osx
osx_image: xcode8
osx_image: xcode9
cache:
- cocoapods
env:
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -70,6 +71,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Configurations/BoltsSwift-iOS.xcconfig
Expand Up @@ -16,6 +16,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.ios

IPHONEOS_DEPLOYMENT_TARGET = 8.0

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Sources/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwift-macOS.xcconfig
Expand Up @@ -16,6 +16,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.macos

MACOSX_DEPLOYMENT_TARGET = 10.10

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Sources/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwift-tvOS.xcconfig
Expand Up @@ -14,6 +14,6 @@
PRODUCT_NAME = BoltsSwift
PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.tvos

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Sources/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwift-watchOS.xcconfig
Expand Up @@ -14,6 +14,6 @@
PRODUCT_NAME = BoltsSwift
PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.watchos

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Sources/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwiftTests-iOS.xcconfig
Expand Up @@ -15,6 +15,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.ios.tests

IPHONEOS_DEPLOYMENT_TARGET = 8.0

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Tests/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwiftTests-macOS.xcconfig
Expand Up @@ -15,6 +15,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.macos.tests

MACOSX_DEPLOYMENT_TARGET = 10.10

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Tests/Info.plist
2 changes: 1 addition & 1 deletion Configurations/BoltsSwiftTests-tvOS.xcconfig
Expand Up @@ -13,6 +13,6 @@
PRODUCT_NAME = BoltsSwiftTests
PRODUCT_BUNDLE_IDENTIFIER = com.bolts.swift.tvos.tests

SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.0

INFOPLIST_FILE = $(SRCROOT)/Tests/Info.plist
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -161,4 +161,4 @@ We want to make contributing to this project as easy and transparent as possible
[carthage-link]: https://github.com/carthage/carthage

[platforms-svg]: http://img.shields.io/cocoapods/p/Bolts-Swift.svg?style=flat
[swift-version-svg]: https://img.shields.io/badge/Swift-3.0.x-orange.svg
[swift-version-svg]: https://img.shields.io/badge/Swift-4.0.x-orange.svg
6 changes: 3 additions & 3 deletions Sources/BoltsSwift/Task.swift
Expand Up @@ -93,7 +93,7 @@ public final class Task<TResult> {
}

class func emptyTask() -> Task<Void> {
return Task<Void>(state: .success())
return Task<Void>(state: .success(()))
}

// MARK: Execute
Expand All @@ -107,7 +107,7 @@ public final class Task<TResult> {
- parameter closure: The closure that returns the result of the task.
The returned task will complete when the closure completes.
*/
public convenience init(_ executor: Executor = .default, closure: @escaping ((Void) throws -> TResult)) {
public convenience init(_ executor: Executor = .default, closure: @escaping (() throws -> TResult)) {
self.init(state: .pending())
executor.execute {
self.trySet(state: TaskState.fromClosure(closure))
Expand All @@ -123,7 +123,7 @@ public final class Task<TResult> {

- returns: A task that will continue with the task returned by the given closure.
*/
public class func execute(_ executor: Executor = .default, closure: @escaping ((Void) throws -> TResult)) -> Task {
public class func execute(_ executor: Executor = .default, closure: @escaping (() throws -> TResult)) -> Task {
return Task(executor, closure: closure)
}

Expand Down
16 changes: 8 additions & 8 deletions Tests/ExecutorTests.swift
Expand Up @@ -13,7 +13,7 @@ import BoltsSwift
class ExecutorTests: XCTestCase {

func testDefaultExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

var finished = false
Executor.default.execute {
Expand All @@ -26,7 +26,7 @@ class ExecutorTests: XCTestCase {
}

func testImmediateExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

var finished = false
Executor.immediate.execute {
Expand All @@ -39,7 +39,7 @@ class ExecutorTests: XCTestCase {
}

func testMainThreadSyncExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

var finished = false
Executor.mainThread.execute {
Expand All @@ -52,7 +52,7 @@ class ExecutorTests: XCTestCase {
}

func testMainThreadAsyncExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

var finished = false
DispatchQueue.global(qos: .default).async {
Expand All @@ -66,7 +66,7 @@ class ExecutorTests: XCTestCase {
}

func testQueueExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)
let semaphore = DispatchSemaphore(value: 0)
var finished = false

Expand All @@ -83,7 +83,7 @@ class ExecutorTests: XCTestCase {
}

func testClosureExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

Executor.closure { closure in
closure()
Expand All @@ -95,7 +95,7 @@ class ExecutorTests: XCTestCase {
}

func testEscapingClosureExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)

Executor.escapingClosure { closure in
closure()
Expand All @@ -107,7 +107,7 @@ class ExecutorTests: XCTestCase {
}

func testOperationQueueExecute() {
let expectation = self.expectation(description: currentTestName)
let expectation = self.expectation(description: name)
let semaphore = DispatchSemaphore(value: 0)
var finished = false

Expand Down
16 changes: 8 additions & 8 deletions Tests/TaskCompletionSourceTests.swift
Expand Up @@ -27,7 +27,7 @@ class TaskCompletionSourceTests: XCTestCase {
let tcs = TaskCompletionSource<String>()
let task = tcs.task

tcs.set(result: currentTestName)
tcs.set(result: name)

XCTAssertTrue(task.completed)
XCTAssertNotNil(task.result)
Expand All @@ -44,7 +44,7 @@ class TaskCompletionSourceTests: XCTestCase {
XCTAssertTrue(task.completed)
XCTAssertTrue(task.faulted)
XCTAssertNotNil(task.error)
XCTAssertEqual(task.error as? NSError, error)
XCTAssertEqual(task.error as NSError?, error)
}

func testCancel() {
Expand All @@ -61,7 +61,7 @@ class TaskCompletionSourceTests: XCTestCase {
let sut = TaskCompletionSource<String>()
let task = sut.task

let success = sut.trySet(result: currentTestName)
let success = sut.trySet(result: name)

XCTAssertTrue(success)
XCTAssertTrue(task.completed)
Expand All @@ -80,7 +80,7 @@ class TaskCompletionSourceTests: XCTestCase {
XCTAssertTrue(task.completed)
XCTAssertTrue(task.faulted)
XCTAssertNotNil(task.error)
XCTAssertEqual(task.error as? NSError, error)
XCTAssertEqual(task.error as NSError?, error)
}

func testTryCancelReturningTrue() {
Expand All @@ -96,17 +96,17 @@ class TaskCompletionSourceTests: XCTestCase {

func testTrySetResultReturningFalse() {
let sut = TaskCompletionSource<String>()
sut.set(result: currentTestName)
sut.set(result: name)

let success = sut.trySet(result: currentTestName)
let success = sut.trySet(result: name)

XCTAssertFalse(success)
}

func testTrySetErrorReturningFalse() {
let error = NSError(domain: "com.bolts", code: 1, userInfo: nil)
let sut = TaskCompletionSource<String>()
sut.set(result: currentTestName)
sut.set(result: name)

let success = sut.trySet(error: error)

Expand All @@ -115,7 +115,7 @@ class TaskCompletionSourceTests: XCTestCase {

func testTryCancelReturningFalse() {
let sut = TaskCompletionSource<String>()
sut.set(result: currentTestName)
sut.set(result: name)
let success = sut.tryCancel()
XCTAssertFalse(success)
}
Expand Down