Skip to content

Commit c4df572

Browse files
committed
Conversion to Swift 5.
1 parent f38dab2 commit c4df572

File tree

10 files changed

+55
-49
lines changed

10 files changed

+55
-49
lines changed

LibreMonitor.xcodeproj/project.pbxproj

+16-17
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
TargetAttributes = {
526526
C6822D611DB13F2200D08393 = {
527527
CreatedOnToolsVersion = 8.0;
528-
LastSwiftMigration = 1000;
528+
LastSwiftMigration = 1020;
529529
ProvisioningStyle = Automatic;
530530
SystemCapabilities = {
531531
com.apple.BackgroundModes = {
@@ -538,24 +538,23 @@
538538
};
539539
C6822D7A1DB13F2200D08393 = {
540540
CreatedOnToolsVersion = 8.0;
541-
LastSwiftMigration = 1000;
541+
LastSwiftMigration = 1020;
542542
ProvisioningStyle = Automatic;
543543
TestTargetID = C6822D611DB13F2200D08393;
544544
};
545545
C6822D851DB13F2200D08393 = {
546546
CreatedOnToolsVersion = 8.0;
547-
LastSwiftMigration = 1000;
547+
LastSwiftMigration = 1020;
548548
ProvisioningStyle = Automatic;
549549
TestTargetID = C6822D611DB13F2200D08393;
550550
};
551551
};
552552
};
553553
buildConfigurationList = C6822D5D1DB13F2200D08393 /* Build configuration list for PBXProject "LibreMonitor" */;
554554
compatibilityVersion = "Xcode 3.1";
555-
developmentRegion = English;
555+
developmentRegion = en;
556556
hasScannedForEncodings = 0;
557557
knownRegions = (
558-
English,
559558
en,
560559
Base,
561560
);
@@ -942,13 +941,13 @@
942941
CODE_SIGN_ENTITLEMENTS = LibreMonitor/LibreMonitor.entitlements;
943942
DEVELOPMENT_TEAM = 26F6YWJYL8;
944943
INFOPLIST_FILE = LibreMonitor/Info.plist;
945-
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
944+
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
946945
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
947946
PRODUCT_BUNDLE_IDENTIFIER = "$(MAIN_APP_BUNDLE_IDENTIFIER)";
948947
PRODUCT_NAME = "$(TARGET_NAME)";
949948
SWIFT_OBJC_BRIDGING_HEADER = "LibreMonitor/LibreMonitor-Bridging-Header.h";
950949
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
951-
SWIFT_VERSION = 4.2;
950+
SWIFT_VERSION = 5.0;
952951
};
953952
name = Debug;
954953
};
@@ -962,12 +961,12 @@
962961
CODE_SIGN_ENTITLEMENTS = LibreMonitor/LibreMonitor.entitlements;
963962
DEVELOPMENT_TEAM = 26F6YWJYL8;
964963
INFOPLIST_FILE = LibreMonitor/Info.plist;
965-
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
964+
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
966965
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
967966
PRODUCT_BUNDLE_IDENTIFIER = "$(MAIN_APP_BUNDLE_IDENTIFIER)";
968967
PRODUCT_NAME = "$(TARGET_NAME)";
969968
SWIFT_OBJC_BRIDGING_HEADER = "LibreMonitor/LibreMonitor-Bridging-Header.h";
970-
SWIFT_VERSION = 4.2;
969+
SWIFT_VERSION = 5.0;
971970
};
972971
name = Release;
973972
};
@@ -977,15 +976,15 @@
977976
buildSettings = {
978977
BUNDLE_LOADER = "$(TEST_HOST)";
979978
CLANG_ENABLE_MODULES = YES;
980-
DEVELOPMENT_TEAM = "";
979+
DEVELOPMENT_TEAM = 26F6YWJYL8;
981980
INFOPLIST_FILE = LibreMonitorTests/Info.plist;
982981
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
983982
NEW_SETTING = "";
984983
PRODUCT_BUNDLE_IDENTIFIER = UPP.LibreMonitorTests;
985984
PRODUCT_NAME = "$(TARGET_NAME)";
986985
SWIFT_OBJC_BRIDGING_HEADER = "LibreMonitorTests/LibreMonitorTests-Bridging-Header.h";
987986
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
988-
SWIFT_VERSION = 4.2;
987+
SWIFT_VERSION = 5.0;
989988
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LibreMonitor.app/LibreMonitor";
990989
};
991990
name = Debug;
@@ -996,14 +995,14 @@
996995
buildSettings = {
997996
BUNDLE_LOADER = "$(TEST_HOST)";
998997
CLANG_ENABLE_MODULES = YES;
999-
DEVELOPMENT_TEAM = "";
998+
DEVELOPMENT_TEAM = 26F6YWJYL8;
1000999
INFOPLIST_FILE = LibreMonitorTests/Info.plist;
10011000
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
10021001
NEW_SETTING = "";
10031002
PRODUCT_BUNDLE_IDENTIFIER = UPP.LibreMonitorTests;
10041003
PRODUCT_NAME = "$(TARGET_NAME)";
10051004
SWIFT_OBJC_BRIDGING_HEADER = "LibreMonitorTests/LibreMonitorTests-Bridging-Header.h";
1006-
SWIFT_VERSION = 4.2;
1005+
SWIFT_VERSION = 5.0;
10071006
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LibreMonitor.app/LibreMonitor";
10081007
};
10091008
name = Release;
@@ -1013,12 +1012,12 @@
10131012
baseConfigurationReference = 29B84802438A170516B70200 /* Pods-LibreMonitorUITests.debug.xcconfig */;
10141013
buildSettings = {
10151014
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
1016-
DEVELOPMENT_TEAM = "";
1015+
DEVELOPMENT_TEAM = 26F6YWJYL8;
10171016
INFOPLIST_FILE = LibreMonitorUITests/Info.plist;
10181017
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
10191018
PRODUCT_BUNDLE_IDENTIFIER = UPP.LibreMonitorUITests;
10201019
PRODUCT_NAME = "$(TARGET_NAME)";
1021-
SWIFT_VERSION = 4.2;
1020+
SWIFT_VERSION = 5.0;
10221021
TEST_TARGET_NAME = LibreMonitor;
10231022
};
10241023
name = Debug;
@@ -1028,12 +1027,12 @@
10281027
baseConfigurationReference = 10E10B329FE1A294608335D3 /* Pods-LibreMonitorUITests.release.xcconfig */;
10291028
buildSettings = {
10301029
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
1031-
DEVELOPMENT_TEAM = "";
1030+
DEVELOPMENT_TEAM = 26F6YWJYL8;
10321031
INFOPLIST_FILE = LibreMonitorUITests/Info.plist;
10331032
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
10341033
PRODUCT_BUNDLE_IDENTIFIER = UPP.LibreMonitorUITests;
10351034
PRODUCT_NAME = "$(TARGET_NAME)";
1036-
SWIFT_VERSION = 4.2;
1035+
SWIFT_VERSION = 5.0;
10371036
TEST_TARGET_NAME = LibreMonitor;
10381037
};
10391038
name = Release;

LibreMonitor.xcworkspace/xcuserdata/Uwe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+16-16
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
ignoreCount = "0"
3535
continueAfterRunningActions = "No"
3636
filePath = "LibreMonitor/Bluetooth/MiaoMiaoManager.swift"
37-
timestampString = "578429314.260875"
37+
timestampString = "578604836.157402"
3838
startingColumnNumber = "9223372036854775807"
3939
endingColumnNumber = "9223372036854775807"
40-
startingLineNumber = "524"
41-
endingLineNumber = "524"
40+
startingLineNumber = "528"
41+
endingLineNumber = "528"
4242
landmarkName = "peripheral(_:didUpdateNotificationStateFor:error:)"
4343
landmarkType = "7">
4444
</BreakpointContent>
@@ -50,13 +50,13 @@
5050
ignoreCount = "0"
5151
continueAfterRunningActions = "No"
5252
filePath = "LibreMonitor/Bluetooth/MiaoMiaoManager.swift"
53-
timestampString = "578429314.261102"
53+
timestampString = "578604836.15748"
5454
startingColumnNumber = "9223372036854775807"
5555
endingColumnNumber = "9223372036854775807"
56-
startingLineNumber = "613"
57-
endingLineNumber = "613"
58-
landmarkName = "peripheral(_:didUpdateValueFor:error:)"
59-
landmarkType = "7">
56+
startingLineNumber = "617"
57+
endingLineNumber = "617"
58+
landmarkName = "MiaoMiaoManager"
59+
landmarkType = "3">
6060
</BreakpointContent>
6161
</BreakpointProxy>
6262
<BreakpointProxy
@@ -66,13 +66,13 @@
6666
ignoreCount = "0"
6767
continueAfterRunningActions = "No"
6868
filePath = "LibreMonitor/Bluetooth/MiaoMiaoManager.swift"
69-
timestampString = "578429314.261165"
69+
timestampString = "578604836.157541"
7070
startingColumnNumber = "9223372036854775807"
7171
endingColumnNumber = "9223372036854775807"
72-
startingLineNumber = "615"
73-
endingLineNumber = "615"
74-
landmarkName = "MiaoMiaoManager"
75-
landmarkType = "3">
72+
startingLineNumber = "619"
73+
endingLineNumber = "619"
74+
landmarkName = "peripheral(_:didWriteValueFor:error:)"
75+
landmarkType = "7">
7676
</BreakpointContent>
7777
</BreakpointProxy>
7878
<BreakpointProxy
@@ -82,11 +82,11 @@
8282
ignoreCount = "0"
8383
continueAfterRunningActions = "No"
8484
filePath = "LibreMonitor/Bluetooth/MiaoMiaoManager.swift"
85-
timestampString = "578429314.261223"
85+
timestampString = "578604836.157601"
8686
startingColumnNumber = "9223372036854775807"
8787
endingColumnNumber = "9223372036854775807"
88-
startingLineNumber = "308"
89-
endingLineNumber = "308"
88+
startingLineNumber = "310"
89+
endingLineNumber = "310"
9090
landmarkName = "centralManager(_:willRestoreState:)"
9191
landmarkType = "7">
9292
</BreakpointContent>

LibreMonitor/Bluetooth/MiaoMiaoManager.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ final class MiaoMiaoManager: NSObject, CBCentralManagerDelegate, CBPeripheralDel
300300
state = .Unassigned
301301
case .poweredOn:
302302
scanForMiaoMiao() // power was switched on, while app is running -> reconnect.
303+
@unknown default:
304+
fatalError("Failed due to unkown default, Uwe!")
303305
}
304306
}
305307

@@ -329,6 +331,8 @@ final class MiaoMiaoManager: NSObject, CBCentralManagerDelegate, CBPeripheralDel
329331
state = .Unassigned
330332
case .poweredOn: // Scanning will not work in background with MiaoMiao (since MiaoMiao does not advertise its services)
331333
scanForMiaoMiao() // power was switched on, while app is running
334+
@unknown default:
335+
fatalError("Failed due to unkown default, Uwe!")
332336
}
333337
}
334338
}
@@ -626,7 +630,7 @@ final class MiaoMiaoManager: NSObject, CBCentralManagerDelegate, CBPeripheralDel
626630
// Confirm (to replace) the sensor. Iif a new sensor is detected and shall be used, send this command (0xD301)
627631
func confirmSensor() {
628632
if let writeCharacteristic = writeCharacteristic {
629-
peripheral?.writeValue(Data.init(bytes: [0xD3, 0x01]), for: writeCharacteristic, type: .withResponse)
633+
peripheral?.writeValue(Data([0xD3, 0x01]), for: writeCharacteristic, type: .withResponse)
630634
}
631635
}
632636

@@ -635,14 +639,14 @@ final class MiaoMiaoManager: NSObject, CBCentralManagerDelegate, CBPeripheralDel
635639
confirmSensor()
636640
resetBuffer()
637641
timer?.invalidate()
638-
peripheral?.writeValue(Data.init(bytes: [0xF0]), for: writeCharacteristic, type: .withResponse)
642+
peripheral?.writeValue(Data([0xF0]), for: writeCharacteristic, type: .withResponse)
639643
}
640644
}
641645

642646
func testL2Transmission() {
643647
if let writeCharacteristic = writeCharacteristic {
644648
// peripheral?.writeValue(Data.init(bytes: [0x00, 0xfa, 0x01]), for: writeCharacteristic, type: .withResponse)
645-
peripheral?.writeValue(Data.init(bytes: [0x02, 0xfa, 0x00]), for: writeCharacteristic, type: .withResponse)
649+
peripheral?.writeValue(Data([0x02, 0xfa, 0x00]), for: writeCharacteristic, type: .withResponse)
646650
// peripheral?.writeValue(Data.init(bytes: [0x04, 0xfa, 0x02]), for: writeCharacteristic, type: .withResponse)
647651
// peripheral?.writeValue(Data.init(bytes: [0x01, 0x0000, 0x0008]), for: writeCharacteristic, type: .withResponse)
648652
}

LibreMonitor/GlucoseCDTVC.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class GlucoseCDTVC: FetchedResultsTableViewController {
3232
request.predicate = nil // all
3333
fetchedResultsController = NSFetchedResultsController<BloodGlucose>(fetchRequest: request, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)
3434
fetchedResultsController?.delegate = self
35-
try? fetchedResultsController?.performFetch()
35+
((try? fetchedResultsController?.performFetch()) as ()??)
3636
tableView.reloadData()
3737
}
3838
}

LibreMonitor/Managers/LibreUtils.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class LibreUtils {
4040
modifiedPatch += patch[320..<344] // footer
4141

4242
// 2018-11-03: Uwe: fake uuid
43-
return SensorData(uuid: Data(bytes: [0x00]), bytes: modifiedPatch)!.bytesWithCorrectCRC()
43+
return SensorData(uuid: Data([0x00]), bytes: modifiedPatch)!.bytesWithCorrectCRC()
44+
// return SensorData(uuid: Data(bytes: [0x00]), bytes: modifiedPatch)!.bytesWithCorrectCRC()
4445
// return SensorData(bytes: modifiedPatch)!.bytesWithCorrectCRC()
4546

4647
}

LibreMonitor/ViewControllers/BloodGlucoseEntryEditTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ final class BloodGlucoseEntryEditTableViewController: UITableViewController {
102102
@IBAction func saveButtonPressed(_ sender: UIBarButtonItem) {
103103
bloodGlucose?.managedObjectContext?.undoManager?.endUndoGrouping()
104104
bloodGlucose?.managedObjectContext?.undoManager?.removeAllActions()
105-
try? bloodGlucose?.managedObjectContext?.save()
105+
((try? bloodGlucose?.managedObjectContext?.save()) as ()??)
106106
presentingViewController?.dismiss(animated: true, completion: nil)
107107
}
108108

LibreMonitor/ViewControllers/BloodSugarTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ final class BloodSugarTableViewController: UITableViewController, MiaoMiaoManage
503503
uploader?.processFreestyleLibreHistoryEntries(nightscoutEntries: nightscoutEntries)
504504
nightscoutEntries = []
505505
}
506-
try? persistentContainer?.viewContext.save()
506+
((try? persistentContainer?.viewContext.save()) as ()??)
507507

508508
} catch {
509509
fatalError("Failed to fetch BloodGlucose: \(error)")

LibreMonitor/ViewControllers/FetchedResultsTableViewController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class FetchedResultsTableViewController: UITableViewController, NSFetchedResults
3434
case .move:
3535
tableView.deleteRows(at: [indexPath!], with: .fade)
3636
tableView.insertRows(at: [newIndexPath!], with: .fade)
37+
@unknown default:
38+
fatalError("Failed due to unkown default, Uwe!")
3739
}
3840
}
3941

LibreMonitor/Views/BloodSugarGraphView.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ final class BloodSugarGraphView: LineChartView {
132132
let timeIntervall = $0.date.timeIntervalSince1970
133133
trendEntries.append(ChartDataEntry(x: timeIntervall, y: $0.glucose))
134134
}
135-
let trendLineChartDataSet = LineChartDataSet(values: trendEntries, label: "Trend")
135+
let trendLineChartDataSet = LineChartDataSet(entries: trendEntries, label: "Trend")
136136
trendLineChartDataSet.drawValuesEnabled = false
137137
return trendLineChartDataSet
138138
}
@@ -144,7 +144,7 @@ final class BloodSugarGraphView: LineChartView {
144144
let timeIntervall = $0.date.timeIntervalSince1970
145145
historyEntries.append(ChartDataEntry(x: timeIntervall, y: $0.glucose))
146146
}
147-
let historyLineChartDataSet = LineChartDataSet(values: historyEntries, label: "History")
147+
let historyLineChartDataSet = LineChartDataSet(entries: historyEntries, label: "History")
148148
historyLineChartDataSet.setColor(NSUIColor.blue, alpha: CGFloat(1.0))
149149
historyLineChartDataSet.setCircleColor(NSUIColor.blue)
150150
return historyLineChartDataSet
@@ -164,7 +164,7 @@ final class BloodSugarGraphView: LineChartView {
164164
oopHistoryEntries.append(ChartDataEntry(x: timeIntervall, y: oopCurrentValue.currentBg))
165165
}
166166
}
167-
let oopHistoryLineChartDataSet = LineChartDataSet(values: oopHistoryEntries, label: "OOP")
167+
let oopHistoryLineChartDataSet = LineChartDataSet(entries: oopHistoryEntries, label: "OOP")
168168
oopHistoryLineChartDataSet.setColor(NSUIColor.red, alpha: CGFloat(1.0))
169169
oopHistoryLineChartDataSet.setCircleColor(NSUIColor.red)
170170
oopHistoryLineChartDataSet.circleRadius = 3.0
@@ -181,7 +181,7 @@ final class BloodSugarGraphView: LineChartView {
181181
let timeIntervall = $0.date.timeIntervalSince1970
182182
newTrendEntries.append(ChartDataEntry(x: timeIntervall, y: $0.temperatureAlgorithmGlucose))
183183
}
184-
let newTrendLineChartDataSet = LineChartDataSet(values: newTrendEntries, label: "New Trend")
184+
let newTrendLineChartDataSet = LineChartDataSet(entries: newTrendEntries, label: "New Trend")
185185
newTrendLineChartDataSet.setColor(NSUIColor.darkGray, alpha: CGFloat(1.0))
186186
newTrendLineChartDataSet.setCircleColor(NSUIColor.darkGray)
187187
newTrendLineChartDataSet.circleRadius = 3.0
@@ -195,7 +195,7 @@ final class BloodSugarGraphView: LineChartView {
195195
let timeIntervall = $0.date.timeIntervalSince1970 // Test - TimeInterval(60*5)
196196
newHistoryEntries.append(ChartDataEntry(x: timeIntervall, y: $0.temperatureAlgorithmGlucose))
197197
}
198-
let newHistoryLineChartDataSet = LineChartDataSet(values: newHistoryEntries, label: "New History")
198+
let newHistoryLineChartDataSet = LineChartDataSet(entries: newHistoryEntries, label: "New History")
199199
newHistoryLineChartDataSet.setColor(NSUIColor.darkGray, alpha: CGFloat(1.0))
200200
newHistoryLineChartDataSet.setCircleColor(NSUIColor.darkGray)
201201
newHistoryLineChartDataSet.circleRadius = 3.0
@@ -219,7 +219,7 @@ final class BloodSugarGraphView: LineChartView {
219219
let p4 = p3 + 0.65 * (p3 - p1) + 0.2 * (p3 - p2)
220220
let t4 = trendMeasurements[2].date.timeIntervalSince1970 + 0.8 * (trendMeasurements[2].date.timeIntervalSince1970 - trendMeasurements[12].date.timeIntervalSince1970)
221221
testEntries.append(ChartDataEntry(x: t4, y: p4))
222-
let testLineChartDataSet = LineChartDataSet(values: testEntries, label: "Test")
222+
let testLineChartDataSet = LineChartDataSet(entries: testEntries, label: "Test")
223223
testLineChartDataSet.setColor(NSUIColor.brown, alpha: CGFloat(1.0))
224224
testLineChartDataSet.setCircleColor(NSUIColor.brown)
225225
testLineChartDataSet.circleRadius = 3.0
@@ -238,7 +238,7 @@ final class BloodSugarGraphView: LineChartView {
238238
}
239239
}
240240
}
241-
let fetchedGlucosesLineChartDataSet = LineChartDataSet(values: fetchedGlucosesEntries, label: "current")
241+
let fetchedGlucosesLineChartDataSet = LineChartDataSet(entries: fetchedGlucosesEntries, label: "current")
242242
fetchedGlucosesLineChartDataSet.setColor(NSUIColor.brown, alpha: CGFloat(1.0))
243243
fetchedGlucosesLineChartDataSet.setCircleColor(NSUIColor.brown)
244244
fetchedGlucosesLineChartDataSet.circleRadius = 3.0

LibreMonitorTests/TransmissionTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import Foundation
1010

1111
import XCTest
12-
//@testable import Pods_LibreMonitor
13-
@testable import LibreMonitor
12+
@testable import Pods_LibreMonitor
13+
//@testable import LibreMonitor
1414

1515
class TransmissionTests: XCTestCase {
1616

0 commit comments

Comments
 (0)