Skip to content

Commit

Permalink
Update Bluejay and dependencies to Swift 5 (#200)
Browse files Browse the repository at this point in the history
* Update Bluejay to Swift 5

* Update dependecies to Swift 5

* Use Swift 5 for Bluejay Heart Sensor Demo as well

* Adopt Xcode recommended project settings

* Use Swift 5 for Dittojay Heart Sensor Demo as well

* Bump Bluejay version and Swift version markers

* Update documentation to note Swift 5 and Xcode 10.2.1 as new requirements
  • Loading branch information
kylebrowning authored and Jeremy Chiang committed May 6, 2019
1 parent 1a7c530 commit 1b9e9a0
Show file tree
Hide file tree
Showing 44 changed files with 1,004 additions and 716 deletions.
8 changes: 4 additions & 4 deletions Bluejay.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Pod::Spec.new do |spec|
spec.name = 'Bluejay'
spec.version = '0.8.4'
spec.version = '0.8.5'
spec.license = { type: 'MIT', file: 'LICENSE' }
spec.homepage = 'https://github.com/steamclock/bluejay'
spec.authors = { 'Jeremy Chiang' => 'jeremy@steamclock.com' }
spec.summary = 'Bluejay is a simple Swift framework for building reliable Bluetooth apps.'
spec.homepage = 'https://github.com/steamclock/bluejay'
spec.source = { git: 'https://github.com/steamclock/bluejay.git', tag: 'v0.8.4' }
spec.source = { git: 'https://github.com/steamclock/bluejay.git', tag: 'v0.8.5' }
spec.source_files = 'Bluejay/Bluejay/*.{h,swift}'
spec.framework = 'SystemConfiguration'
spec.platform = :ios, '10.0'
spec.requires_arc = true
spec.dependency 'XCGLogger', '~> 6.1.0'
spec.swift_version = '4.2'
spec.dependency 'XCGLogger', '~> 7.0.0'
spec.swift_version = '5.0'
end
2 changes: 1 addition & 1 deletion Bluejay/.jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ output: ../docs
author: Steamclock Software
author_url: http://steamclock.com
module: Bluejay
module_version: 0.8.4
module_version: 0.8.5
readme: ../README.md
sdk: iphone
copyright: Copyright © 2017 Steamclock Software. All rights reserved.
Expand Down
26 changes: 14 additions & 12 deletions Bluejay/Bluejay.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@
B8383B5C21C3162800F07306 = {
CreatedOnToolsVersion = 10.1;
DevelopmentTeam = GH868RP95T;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
Expand All @@ -579,6 +580,7 @@
B87FDD5D21E567150010D6CF = {
CreatedOnToolsVersion = 10.1;
DevelopmentTeam = GH868RP95T;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
Expand All @@ -589,14 +591,14 @@
B8C70F741E1C22850006CF58 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = GH868RP95T;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = B8C70F6F1E1C22850006CF58 /* Build configuration list for PBXProject "Bluejay" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -669,7 +671,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-BluejayHeartSensorDemo/Pods-BluejayHeartSensorDemo-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-BluejayHeartSensorDemo/Pods-BluejayHeartSensorDemo-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/ObjcExceptionBridging/ObjcExceptionBridging.framework",
"${BUILT_PRODUCTS_DIR}/XCGLogger/XCGLogger.framework",
);
Expand All @@ -680,7 +682,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BluejayHeartSensorDemo/Pods-BluejayHeartSensorDemo-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BluejayHeartSensorDemo/Pods-BluejayHeartSensorDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
A3B0253955770A9E58E075E5 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -720,7 +722,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-DittojayHeartSensorDemo/Pods-DittojayHeartSensorDemo-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-DittojayHeartSensorDemo/Pods-DittojayHeartSensorDemo-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/ObjcExceptionBridging/ObjcExceptionBridging.framework",
"${BUILT_PRODUCTS_DIR}/XCGLogger/XCGLogger.framework",
);
Expand All @@ -731,7 +733,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DittojayHeartSensorDemo/Pods-DittojayHeartSensorDemo-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DittojayHeartSensorDemo/Pods-DittojayHeartSensorDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
E74B2676FBABC2E126DD9A0D /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -911,7 +913,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.BluejayHeartSensorDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -937,7 +939,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.BluejayHeartSensorDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -963,7 +965,7 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.DittojayHeartSensorDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -988,7 +990,7 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.DittojayHeartSensorDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand Down Expand Up @@ -1128,7 +1130,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1151,7 +1153,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.steamclock.Bluejay;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions Bluejay/Bluejay/Bluejay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,8 @@ extension Bluejay: CBCentralManagerDelegate {
for observer in self.connectionObservers {
observer.weakReference?.bluetoothAvailable(false)
}
@unknown default:
debugLog("New system level CBCentralManager state added.")
}
}

Expand Down Expand Up @@ -1290,6 +1292,8 @@ extension Bluejay: CBCentralManagerDelegate {
precondition(connectingPeripheral == nil && connectedPeripheral == nil,
"Connecting and connected peripherals are not nil during willRestoreState for state: disconnected.")
disconnectedPeripheralAtRestoration = peripheral
@unknown default:
debugLog("New system level CBCentralManager state added.")
}
}

Expand Down
2 changes: 2 additions & 0 deletions Bluejay/Bluejay/CBManagerState+ReturnString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extension CBManagerState {
case .unauthorized: return "Unauthorized"
case .unknown: return "Unknown"
case .unsupported: return "Unsupported"
@unknown default:
return "Unknown"
}
}

Expand Down
2 changes: 2 additions & 0 deletions Bluejay/Bluejay/CBPeripheralState+ReturnString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extension CBPeripheralState {
case .connecting: return "Connecting"
case .disconnected: return "Disconnected"
case .disconnecting: return "Disconnecting"
@unknown default:
return "Unknown"
}
}

Expand Down
12 changes: 4 additions & 8 deletions Bluejay/Bluejay/CharacteristicIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ public struct CharacteristicIdentifier {
}
}

extension CharacteristicIdentifier: Equatable {
extension CharacteristicIdentifier: Hashable {
/// Check equality between two CharacteristicIdentifiers.
public static func == (lhs: CharacteristicIdentifier, rhs: CharacteristicIdentifier) -> Bool {
return (lhs.uuid == rhs.uuid) && (lhs.service.uuid == rhs.service.uuid)
}
}

extension CharacteristicIdentifier: Hashable {
/// The hash value of the `CBUUID`.
public var hashValue: Int {
let cHashValue = uuid.hashValue
let sHashValue = service.uuid.hashValue
return (cHashValue << 5) &+ cHashValue &+ sHashValue
public func hash(into hasher: inout Hasher) {
hasher.combine(uuid)
hasher.combine(service.uuid)
}
}
2 changes: 1 addition & 1 deletion Bluejay/Bluejay/Data+Extractable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension Data {
throw BluejayError.dataOutOfBounds(start: start, length: length, count: self.count)
}

return self.subdata(in: start..<start + length).withUnsafeBytes { $0.pointee }
return self.subdata(in: start..<start + length).withUnsafeBytes { $0.load(as: T.self) }
}

}
2 changes: 1 addition & 1 deletion Bluejay/Bluejay/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.4</string>
<string>0.8.5</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
8 changes: 1 addition & 7 deletions Bluejay/Bluejay/PeripheralIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ public struct PeripheralIdentifier {
}
}

extension PeripheralIdentifier: Equatable {
extension PeripheralIdentifier: Hashable {
public static func == (lhs: PeripheralIdentifier, rhs: PeripheralIdentifier) -> Bool {
return lhs.uuid == rhs.uuid
}
}

extension PeripheralIdentifier: Hashable {
public var hashValue: Int {
return uuid.hashValue
}
}
6 changes: 3 additions & 3 deletions Bluejay/Bluejay/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Scan: Queueable {
refreshTimer(identifier: newDiscovery.peripheralIdentifier.uuid)
}

if let indexOfExistingDiscovery = discoveries.index(where: { existingDiscovery -> Bool in
if let indexOfExistingDiscovery = discoveries.firstIndex(where: { existingDiscovery -> Bool in
existingDiscovery.peripheralIdentifier == peripheralIdentifier
}) {
let existingDiscovery = discoveries[indexOfExistingDiscovery]
Expand Down Expand Up @@ -242,7 +242,7 @@ class Scan: Queueable {
}

private func refreshTimer(identifier: UUID) {
if let indexOfExistingTimer = timers.index(where: { uuid, _ -> Bool in
if let indexOfExistingTimer = timers.firstIndex(where: { uuid, _ -> Bool in
uuid == identifier
}) {
timers[indexOfExistingTimer].1?.invalidate()
Expand All @@ -267,7 +267,7 @@ class Scan: Queueable {
return
}

if let indexOfExpiredDiscovery = discoveries.index(where: { discovery -> Bool in
if let indexOfExpiredDiscovery = discoveries.firstIndex(where: { discovery -> Bool in
discovery.peripheralIdentifier.uuid == identifier
}) {
let expiredDiscovery = discoveries[indexOfExpiredDiscovery]
Expand Down
10 changes: 1 addition & 9 deletions Bluejay/Bluejay/ServiceIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,10 @@ public struct ServiceIdentifier {
}
}

extension ServiceIdentifier: Equatable {
extension ServiceIdentifier: Hashable {

/// Check equality between two ServiceIdentifier.
public static func == (lhs: ServiceIdentifier, rhs: ServiceIdentifier) -> Bool {
return lhs.uuid == rhs.uuid
}
}

extension ServiceIdentifier: Hashable {

/// The hash value of the `CBUUID`.
public var hashValue: Int {
return uuid.hashValue
}
}
2 changes: 1 addition & 1 deletion Bluejay/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def core_pods

# Pods for Bluejay
pod 'SwiftLint'
pod 'XCGLogger', '~> 6.1.0'
pod 'XCGLogger', '~> 7.0.0'
end

def demo_pods
Expand Down
18 changes: 9 additions & 9 deletions Bluejay/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ PODS:
- ObjcExceptionBridging (1.0.1):
- ObjcExceptionBridging/ObjcExceptionBridging (= 1.0.1)
- ObjcExceptionBridging/ObjcExceptionBridging (1.0.1)
- SwiftLint (0.29.3)
- XCGLogger (6.1.0):
- XCGLogger/Core (= 6.1.0)
- XCGLogger/Core (6.1.0):
- SwiftLint (0.31.0)
- XCGLogger (7.0.0):
- XCGLogger/Core (= 7.0.0)
- XCGLogger/Core (7.0.0):
- ObjcExceptionBridging

DEPENDENCIES:
- SwiftLint
- XCGLogger (~> 6.1.0)
- XCGLogger (~> 7.0.0)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
Expand All @@ -20,9 +20,9 @@ SPEC REPOS:

SPEC CHECKSUMS:
ObjcExceptionBridging: c30e00eb3700467e695faeea30e26e18bd445001
SwiftLint: bfa7ca7b4d170cfaf0d236ca3ffd969e88a2f002
XCGLogger: 7f7f43f15dfe3a305fa1342b7dc29af656289abd
SwiftLint: 7a0227733d786395817373b2d0ca799fd0093ff3
XCGLogger: 0434f15e3909cdc450bb63faf638b8792ab782ab

PODFILE CHECKSUM: 81cfa7eec990701e4f1e066308c86f6d94e9e854
PODFILE CHECKSUM: 5ce80d224aec6c7b35b5ca374e1320448cffb359

COCOAPODS: 1.5.3
COCOAPODS: 1.6.0
18 changes: 9 additions & 9 deletions Bluejay/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b9e9a0

Please sign in to comment.