From 2df81cbe06cb34676bcfc4b291b6900fb60b37c9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 3 Apr 2018 17:11:20 -0700 Subject: [PATCH 1/3] Perform automated XCode 9.3 update --- Loop.xcodeproj/project.pbxproj | 6 +++++- .../xcschemes/Complication - WatchApp.xcscheme | 4 +--- .../xcshareddata/xcschemes/DoseMathTests.xcscheme | 4 +--- .../xcshareddata/xcschemes/Loop Status Extension.xcscheme | 4 +--- Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme | 8 +++----- Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme | 4 +--- .../xcschemes/Notification - WatchApp.xcscheme | 4 +--- Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme | 4 +--- 8 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 478b92151c..25538ce556 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -1347,7 +1347,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "LoopKit Authors"; TargetAttributes = { 43776F8B1B8022E90074EA36 = { @@ -2036,12 +2036,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -2101,12 +2103,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/Loop.xcodeproj/xcshareddata/xcschemes/Complication - WatchApp.xcscheme b/Loop.xcodeproj/xcshareddata/xcschemes/Complication - WatchApp.xcscheme index 2d94260fca..ab563e3f5a 100644 --- a/Loop.xcodeproj/xcshareddata/xcschemes/Complication - WatchApp.xcscheme +++ b/Loop.xcodeproj/xcshareddata/xcschemes/Complication - WatchApp.xcscheme @@ -1,6 +1,6 @@ @@ -61,7 +60,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "" selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme b/Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme index b2c46e209e..301b74132b 100644 --- a/Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme +++ b/Loop.xcodeproj/xcshareddata/xcschemes/Loop.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,7 +56,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme b/Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme index b74e4c3f3e..337f33d7fa 100644 --- a/Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme +++ b/Loop.xcodeproj/xcshareddata/xcschemes/LoopTests.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 3 Apr 2018 17:18:39 -0700 Subject: [PATCH 2/3] Correct all XCode 9.3 warnings that have an automated fix (ie. flatMap -> compactMap) --- Common/Models/StatusExtensionContext.swift | 4 ++-- Common/Models/WatchContext.swift | 2 +- Loop/Extensions/NSUserDefaults.swift | 2 +- Loop/Managers/CGM/CGMManager.swift | 2 +- Loop/Managers/CGM/EnliteCGMManager.swift | 2 +- .../RadioSelectionTableViewController.swift | 4 ++-- LoopUI/Managers/StatusChartsManager.swift | 12 ++++++------ LoopUI/Views/ChartPointsContextFillLayer.swift | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Common/Models/StatusExtensionContext.swift b/Common/Models/StatusExtensionContext.swift index 9430895822..3847b9da20 100644 --- a/Common/Models/StatusExtensionContext.swift +++ b/Common/Models/StatusExtensionContext.swift @@ -287,7 +287,7 @@ struct StatusExtensionContext: RawRepresentable { } if let rawValue = rawValue["glucose"] as? [GlucoseContext.RawValue] { - glucose = rawValue.flatMap({return GlucoseContext(rawValue: $0)}) + glucose = rawValue.compactMap({return GlucoseContext(rawValue: $0)}) } if let rawValue = rawValue["predictedGlucose"] as? PredictedGlucoseContext.RawValue { @@ -311,7 +311,7 @@ struct StatusExtensionContext: RawRepresentable { activeInsulin = rawValue["activeInsulin"] as? Double if let rawValue = rawValue["targetRanges"] as? [DatedRangeContext.RawValue] { - targetRanges = rawValue.flatMap({return DatedRangeContext(rawValue: $0)}) + targetRanges = rawValue.compactMap({return DatedRangeContext(rawValue: $0)}) } if let rawValue = rawValue["temporaryOverride"] as? DatedRangeContext.RawValue { diff --git a/Common/Models/WatchContext.swift b/Common/Models/WatchContext.swift index 1b1f968824..1a3bb4da5e 100644 --- a/Common/Models/WatchContext.swift +++ b/Common/Models/WatchContext.swift @@ -76,7 +76,7 @@ final class WatchContext: NSObject, RawRepresentable { } if let configuredOverrideContextsRawValues = rawValue["coc"] as? [GlucoseRangeScheduleOverrideUserInfo.Context.RawValue] { - configuredOverrideContexts = configuredOverrideContextsRawValues.flatMap(GlucoseRangeScheduleOverrideUserInfo.Context.init(rawValue:)) + configuredOverrideContexts = configuredOverrideContextsRawValues.compactMap(GlucoseRangeScheduleOverrideUserInfo.Context.init(rawValue:)) } IOB = rawValue["iob"] as? Double diff --git a/Loop/Extensions/NSUserDefaults.swift b/Loop/Extensions/NSUserDefaults.swift index 98515b8fec..2e4449d14b 100644 --- a/Loop/Extensions/NSUserDefaults.swift +++ b/Loop/Extensions/NSUserDefaults.swift @@ -184,7 +184,7 @@ extension UserDefaults { guard let rawValue = array(forKey: Key.insulinCounteractionEffects.rawValue) as? [GlucoseEffectVelocity.RawValue] else { return nil } - return rawValue.flatMap { + return rawValue.compactMap { GlucoseEffectVelocity(rawValue: $0) } } diff --git a/Loop/Managers/CGM/CGMManager.swift b/Loop/Managers/CGM/CGMManager.swift index 64615f545a..82424119b3 100644 --- a/Loop/Managers/CGM/CGMManager.swift +++ b/Loop/Managers/CGM/CGMManager.swift @@ -38,7 +38,7 @@ protocol CGMManagerDelegate: class { protocol CGMManager: CustomDebugStringConvertible { - weak var delegate: CGMManagerDelegate? { get set } + var delegate: CGMManagerDelegate? { get set } /// Whether the device is capable of waking the app var providesBLEHeartbeat: Bool { get } diff --git a/Loop/Managers/CGM/EnliteCGMManager.swift b/Loop/Managers/CGM/EnliteCGMManager.swift index 247137c803..876810e9fc 100644 --- a/Loop/Managers/CGM/EnliteCGMManager.swift +++ b/Loop/Managers/CGM/EnliteCGMManager.swift @@ -40,7 +40,7 @@ final class EnliteCGMManager: CGMManager { _ = deviceManager.remoteDataManager.nightscoutService.uploader?.processGlucoseEvents(events, source: device.device.deviceURI) - if let latestSensorEvent = events.flatMap({ $0.glucoseEvent as? RelativeTimestampedGlucoseEvent }).last { + if let latestSensorEvent = events.compactMap({ $0.glucoseEvent as? RelativeTimestampedGlucoseEvent }).last { self.sensorState = EnliteSensorDisplayable(latestSensorEvent) } diff --git a/Loop/View Controllers/RadioSelectionTableViewController.swift b/Loop/View Controllers/RadioSelectionTableViewController.swift index fc13d26427..1b119e30cb 100644 --- a/Loop/View Controllers/RadioSelectionTableViewController.swift +++ b/Loop/View Controllers/RadioSelectionTableViewController.swift @@ -78,7 +78,7 @@ extension RadioSelectionTableViewController { let vc = T() vc.selectedIndex = value.rawValue - vc.options = (0..<2).flatMap({ InsulinDataSource(rawValue: $0) }).map { String(describing: $0) } + vc.options = (0..<2).compactMap({ InsulinDataSource(rawValue: $0) }).map { String(describing: $0) } vc.contextHelp = NSLocalizedString("Insulin delivery can be determined from the pump by either interpreting the event history or comparing the reservoir volume over time. Reading event history allows for a more accurate status graph and uploading up-to-date treatment data to Nightscout, at the cost of faster pump battery drain and the possibility of a higher radio error rate compared to reading only reservoir volume. If the selected source cannot be used for any reason, the system will attempt to fall back to the other option.", comment: "Instructions on selecting an insulin data source") return vc @@ -88,7 +88,7 @@ extension RadioSelectionTableViewController { let vc = T() vc.selectedIndex = value.rawValue - vc.options = (0..<2).flatMap({ BatteryChemistryType(rawValue: $0) }).map { String(describing: $0) } + vc.options = (0..<2).compactMap({ BatteryChemistryType(rawValue: $0) }).map { String(describing: $0) } vc.contextHelp = NSLocalizedString("Alkaline and Lithium batteries decay at differing rates. Alkaline tend to have a linear voltage drop over time whereas lithium cell batteries tend to maintain voltage until halfway through their lifespan. Under normal usage in a Non-MySentry compatible Minimed (x22/x15) insulin pump running Loop, Alkaline batteries last approximately 4 to 5 days. Lithium batteries last between 1-2 weeks. This selection will use different battery voltage decay rates for each of the battery chemistry types and alert the user when a battery is approximately 8 to 10 hours from failure.", comment: "Instructions on selecting battery chemistry type") return vc diff --git a/LoopUI/Managers/StatusChartsManager.swift b/LoopUI/Managers/StatusChartsManager.swift index 8019c33085..476990b437 100644 --- a/LoopUI/Managers/StatusChartsManager.swift +++ b/LoopUI/Managers/StatusChartsManager.swift @@ -417,7 +417,7 @@ public final class StatusChartsManager { frame: frame, innerFrame: innerFrame, settings: chartSettings, - layers: layers.flatMap { $0 } + layers: layers.compactMap { $0 } ) } @@ -487,7 +487,7 @@ public final class StatusChartsManager { iobLine, ] - return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.flatMap { $0 }) + return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.compactMap { $0 }) } public func cobChartWithFrame(_ frame: CGRect) -> Chart? { @@ -544,7 +544,7 @@ public final class StatusChartsManager { cobLine ] - return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.flatMap { $0 }) + return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.compactMap { $0 }) } public func doseChartWithFrame(_ frame: CGRect) -> Chart? { @@ -632,7 +632,7 @@ public final class StatusChartsManager { bolusLayer ] - return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.flatMap { $0 }) + return Chart(frame: frame, innerFrame: innerFrame, settings: chartSettings, layers: layers.compactMap { $0 }) } // MARK: - Carb Effect @@ -765,7 +765,7 @@ public final class StatusChartsManager { frame: frame, innerFrame: innerFrame, settings: chartSettings, - layers: layers.flatMap { $0 } + layers: layers.compactMap { $0 } ) } @@ -893,7 +893,7 @@ public final class StatusChartsManager { frame: frame, innerFrame: coordsSpace.chartInnerFrame, settings: chartSettings, - layers: layers.flatMap { $0 } + layers: layers.compactMap { $0 } ) } diff --git a/LoopUI/Views/ChartPointsContextFillLayer.swift b/LoopUI/Views/ChartPointsContextFillLayer.swift index a2824336ce..220c5b9480 100644 --- a/LoopUI/Views/ChartPointsContextFillLayer.swift +++ b/LoopUI/Views/ChartPointsContextFillLayer.swift @@ -59,7 +59,7 @@ final class ChartPointsFillsLayer: ChartCoordsSpaceLayer { let fills: [ChartPointsFill] init?(xAxis: ChartAxis, yAxis: ChartAxis, fills: [ChartPointsFill?]) { - self.fills = fills.flatMap({ $0 }) + self.fills = fills.compactMap({ $0 }) guard fills.count > 0 else { return nil From 90d9a6c78f4144dbeda2505ca0ea8dde0e68a723 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 3 Apr 2018 17:22:07 -0700 Subject: [PATCH 3/3] Fix cross-module struct initialization warning --- Common/Models/StatusExtensionContext.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Common/Models/StatusExtensionContext.swift b/Common/Models/StatusExtensionContext.swift index 3847b9da20..eb61df6dbd 100644 --- a/Common/Models/StatusExtensionContext.swift +++ b/Common/Models/StatusExtensionContext.swift @@ -257,10 +257,7 @@ extension DatedRangeContext: RawRepresentable { return nil } - self.startDate = startDate - self.endDate = endDate - self.minValue = minValue - self.maxValue = maxValue + self.init(startDate: startDate, endDate: endDate, minValue: minValue, maxValue: maxValue) } }