Skip to content

Commit

Permalink
Support Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 15, 2019
1 parent 6300582 commit b6d4904
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ matrix:
# Test Xcode 10 / Swift 4.2
- os: osx
osx_image: xcode10
# Test Xcode 10.2 / Swift 5
- os: osx
osx_image: xcode10.2

addons:
apt:
packages:
Expand Down
20 changes: 20 additions & 0 deletions Package@swift-5.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version:5.0
import PackageDescription

_ = Package(name: "BluetoothLinux",
products: [
.library(
name: "BluetoothLinux",
targets: ["BluetoothLinux"]
)
],
dependencies: [
.package(url: "https://github.com/PureSwift/Bluetooth.git", .branch("master"))
],
targets: [
.target(name: "BluetoothLinux", dependencies: ["Bluetooth", "CSwiftBluetoothLinux"]),
.target(name: "CSwiftBluetoothLinux"),
.target(name: "CSwiftBluetoothLinuxTest"),
.testTarget(name: "BluetoothLinuxTests", dependencies: ["BluetoothLinux", "CSwiftBluetoothLinuxTest"])
],
swiftLanguageVersions: [.v5])
10 changes: 7 additions & 3 deletions Sources/BluetoothLinux/HostController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ public extension HostController {

static var `default`: HostController? {

#if swift(>=5.0)
guard let deviceIdentifier = try? HCIGetRoute(nil)
else { return nil }
#else
guard let result = try? HCIGetRoute(nil),
let deviceIdentifier = result,
let controller = try? HostController(identifier: deviceIdentifier)
let deviceIdentifier = result
else { return nil }
#endif

return controller
return try? HostController(identifier: deviceIdentifier)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BluetoothLinux/L2CAP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {

let actualBytes = Array(buffer.prefix(actualByteCount))

return Data(bytes: actualBytes)
return Data(actualBytes)
}

private func canRead() throws -> Bool {
Expand Down

0 comments on commit b6d4904

Please sign in to comment.