From 7da0a5a776b812c3c86e1eca3cccde291e2bff2b Mon Sep 17 00:00:00 2001 From: Stefan Trauth Date: Sat, 9 Jul 2022 04:13:09 +0200 Subject: [PATCH] Support watchOS 9 (#60) --- Package.swift | 2 +- Sources/Zephyr.swift | 10 ++++++++++ Zephyr.podspec | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index d578d40..dc494ba 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription let package = Package( name: "Zephyr", - platforms: [.iOS(.v11), .tvOS(.v11)], + platforms: [.iOS(.v11), .tvOS(.v11), .watchOS("9.0")], products: [.library(name: "Zephyr", targets: ["Zephyr"])], targets: [.target(name: "Zephyr", path: "Sources")], swiftLanguageVersions: [.v5] diff --git a/Sources/Zephyr.swift b/Sources/Zephyr.swift index cac9604..dd39a47 100644 --- a/Sources/Zephyr.swift +++ b/Sources/Zephyr.swift @@ -9,6 +9,8 @@ import Foundation #if os(iOS) || os(tvOS) import UIKit +#elseif os(watchOS) +import WatchKit #endif /// Enumerates the Local (`UserDefaults`) and Remote (`NSUNSUbiquitousKeyValueStore`) data stores @@ -234,6 +236,14 @@ private extension Zephyr { name: UIApplication.willEnterForegroundNotification, object: nil) #endif + + #if os(watchOS) + if #available(watchOS 9.0, *) { + NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(notification:)), + name: WKExtension.applicationWillEnterForegroundNotification, + object: nil) + } + #endif } /// Compares the last sync date between `NSUbiquitousKeyValueStore` and `UserDefaults`. diff --git a/Zephyr.podspec b/Zephyr.podspec index 9ebd3bd..55bbf0a 100755 --- a/Zephyr.podspec +++ b/Zephyr.podspec @@ -16,6 +16,7 @@ Pod::Spec.new do |s| # Deployment s.ios.deployment_target = '11.0' s.tvos.deployment_target = '11.0' + s.watchos.deployment_target = '9.0' # Sources s.source = { :git => "https://github.com/ArtSabintsev/Zephyr.git", :tag => s.version.to_s }