From 9428dc0040c1d8ab2ca071083db00eff9e6a3937 Mon Sep 17 00:00:00 2001 From: Zach Date: Wed, 20 Dec 2023 19:01:56 -0700 Subject: [PATCH] Fix platform support (#11) --- .../LocationApplication/LocationApplication.swift | 13 +++++++++---- .../LocationApplicationTests.swift | 10 ++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Sources/ApplicationKit/LocationApplication/LocationApplication.swift b/Sources/ApplicationKit/LocationApplication/LocationApplication.swift index 42ce024..f8c574c 100644 --- a/Sources/ApplicationKit/LocationApplication/LocationApplication.swift +++ b/Sources/ApplicationKit/LocationApplication/LocationApplication.swift @@ -18,20 +18,25 @@ open class LocationApplication: LifecyleApplication, CLLocationManagerDelegate { // MARK: - Open CLLocationManagerDelegate Functions + #if os(iOS) || os(macOS) open func locationManager(_ manager: CLLocationManager, didVisit visit: CLVisit) { } open func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { } open func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { } - open func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { } - open func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { } - open func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { } open func locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint) { } open func locationManager(_ manager: CLLocationManager, didStartMonitoringFor region: CLRegion) { } open func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) { } open func locationManager(_ manager: CLLocationManager, didFailRangingFor beaconConstraint: CLBeaconIdentityConstraint, error: Error) { } open func locationManager(_ manager: CLLocationManager, didFinishDeferredUpdatesWithError error: Error?) { } open func locationManager(_ manager: CLLocationManager, monitoringDidFailFor region: CLRegion?, withError error: Error) { } - open func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { } open func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { } open func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { } + #endif + + #if !os(tvOS) open func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool { false } + #endif + + open func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { } + open func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { } + open func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { } } diff --git a/Tests/ApplicationKitTests/LocationApplicationTests.swift b/Tests/ApplicationKitTests/LocationApplicationTests.swift index 778fe0c..084c5fc 100644 --- a/Tests/ApplicationKitTests/LocationApplicationTests.swift +++ b/Tests/ApplicationKitTests/LocationApplicationTests.swift @@ -4,15 +4,11 @@ import CoreLocation @testable import ApplicationKit class MockLocationManager: LocationManager { - func test() { - delegate?.locationManager?(.init(), didEnterRegion: .init()) - } + } class MyLocationApplication: LocationApplication { - override func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { - print("didEnterRegion: \(region)") - } + } final class LocationApplicationTests: XCTestCase { @@ -32,8 +28,6 @@ final class LocationApplicationTests: XCTestCase { XCTAssertNotNil(locationManager.delegate) XCTAssertTrue(locationManager.delegate is MyLocationApplication) - mockLocationManager?.test() - locationManagerOverride.cancel() XCTAssertNotNil(locationManager.delegate)