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

Migrate to Swift 4 #103

Merged
merged 3 commits into from
Oct 31, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ let package = Package(
.target(name: "ReactiveTask", dependencies: ["Result", "ReactiveSwift"], path: "Sources"),
.testTarget(name: "ReactiveTaskTests", dependencies: ["ReactiveTask", "Quick", "Nimble"]),
],
swiftLanguageVersions: [3]
swiftLanguageVersions: [4]
)
20 changes: 8 additions & 12 deletions ReactiveTask.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -390,7 +391,8 @@
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -406,7 +408,6 @@
INFOPLIST_FILE = Sources/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -420,7 +421,6 @@
INFOPLIST_FILE = Sources/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -435,7 +435,6 @@
INFOPLIST_FILE = Tests/ReactiveTaskTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -450,7 +449,6 @@
INFOPLIST_FILE = Tests/ReactiveTaskTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -468,7 +466,8 @@
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -484,7 +483,6 @@
INFOPLIST_FILE = Sources/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Test;
};
Expand All @@ -499,7 +497,6 @@
INFOPLIST_FILE = Tests/ReactiveTaskTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Test;
};
Expand All @@ -517,7 +514,8 @@
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -533,7 +531,6 @@
INFOPLIST_FILE = Sources/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Profile;
};
Expand All @@ -548,7 +545,6 @@
INFOPLIST_FILE = Tests/ReactiveTaskTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Profile;
};
Expand Down
12 changes: 5 additions & 7 deletions Sources/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,10 @@ private final class Pipe {
channel.setLimit(lowWater: 1)
channel.read(offset: 0, length: Int.max, queue: self.queue) { (done, dispatchData, error) in
if let dispatchData = dispatchData {
let bytes = UnsafeMutablePointer<UInt8>.allocate(capacity: dispatchData.count)
dispatchData.copyBytes(to: bytes, count: dispatchData.count)
let data = Data(bytes: bytes, count: dispatchData.count)
bytes.deinitialize(count: dispatchData.count)
bytes.deallocate(capacity: dispatchData.count)

// Cast DispatchData to Data.
// See https://gist.github.com/mayoff/6e35e263b9ddd04d9b77e5261212be19.
let data = dispatchData as Any as! NSData as Data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️


observer.send(value: data)
}

Expand Down Expand Up @@ -235,7 +233,7 @@ private final class Pipe {

signal.observe(Signal.Observer(value: { data in
let dispatchData = data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> DispatchData in
let buffer = UnsafeBufferPointer(start: bytes, count: data.count)
let buffer = UnsafeRawBufferPointer(start: bytes, count: data.count)
return DispatchData(bytes: buffer)
}

Expand Down