diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 575aa19097..a5c259baa0 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -1881,6 +1881,7 @@ SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; WARNING_CFLAGS = "-Wall"; + WATCHOS_DEPLOYMENT_TARGET = 3.2; }; name = Debug; }; @@ -1939,6 +1940,7 @@ TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; WARNING_CFLAGS = "-Wall"; + WATCHOS_DEPLOYMENT_TARGET = 3.2; }; name = Release; }; diff --git a/WatchApp Extension/ExtensionDelegate.swift b/WatchApp Extension/ExtensionDelegate.swift index c326392944..a8cf4649c0 100644 --- a/WatchApp Extension/ExtensionDelegate.swift +++ b/WatchApp Extension/ExtensionDelegate.swift @@ -101,11 +101,12 @@ final class ExtensionDelegate: NSObject, WKExtensionDelegate { default: break } - #if swift(>=3.2) + + if #available(watchOSApplicationExtension 4.0, *) { task.setTaskCompletedWithSnapshot(false) - #else + } else { task.setTaskCompleted() - #endif + } } } @@ -113,12 +114,12 @@ final class ExtensionDelegate: NSObject, WKExtensionDelegate { private func completePendingConnectivityTasksIfNeeded() { if WCSession.default().activationState == .activated && !WCSession.default().hasContentPending { - pendingConnectivityTasks.forEach { - #if swift(>=3.2) - $0.setTaskCompletedWithSnapshot(false) - #else - $0.setTaskCompleted() - #endif + pendingConnectivityTasks.forEach { (task) in + if #available(watchOSApplicationExtension 4.0, *) { + task.setTaskCompletedWithSnapshot(false) + } else { + task.setTaskCompleted() + } } pendingConnectivityTasks.removeAll() }