Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for visionOS #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/Async Tasks/BeaconMonitoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import Foundation
import CoreLocation

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
extension Tasks {

public final class BeaconMonitoring: AnyTask {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/Async Tasks/LocatePermission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension Tasks {
}
}

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
func requestAlwaysPermission() async throws -> CLAuthorizationStatus {
try await withCheckedThrowingContinuation { continuation in
guard let instance = self.instance else { return }
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftLocation/Async Tasks/RegionMonitoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import Foundation
import CoreLocation

#if !os(visionOS)

extension Tasks {

public final class RegionMonitoring: AnyTask {
Expand Down Expand Up @@ -121,3 +123,5 @@ extension Tasks {
}

}

#endif
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/Async Tasks/VisitsMonitoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import Foundation
import CoreLocation

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
extension Tasks {

public final class VisitsMonitoring: AnyTask {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,23 @@ public enum LocationManagerBridgeEvent {

// MARK: - Region Monitoring

#if !os(visionOS)
case didEnterRegion(_ region: CLRegion)
case didExitRegion(_ region: CLRegion)
case didStartMonitoringFor(_ region: CLRegion)

#endif

// MARK: - Failures

case didFailWithError(_ error: Error)

#if !os(visionOS)
case monitoringDidFailFor(region: CLRegion?, error: Error)

#endif

// MARK: - Visits Monitoring

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
case didVisit(visit: CLVisit)
#endif

Expand All @@ -66,7 +71,7 @@ public enum LocationManagerBridgeEvent {

// MARK: - Beacons

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
case didRange(beacons: [CLBeacon], constraint: CLBeaconIdentityConstraint)
case didFailRanginFor(constraint: CLBeaconIdentityConstraint, error: Error)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public protocol LocationManagerProtocol {
var distanceFilter: CLLocationDistance { get set }
var desiredAccuracy: CLLocationAccuracy { get set }

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
var allowsBackgroundLocationUpdates: Bool { get set }
#endif

Expand All @@ -58,7 +58,7 @@ public protocol LocationManagerProtocol {
func validatePlistConfigurationForTemporaryAccuracy(purposeKey: String) throws
func requestWhenInUseAuthorization()

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
func requestAlwaysAuthorization()
#endif
func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String, completion: ((Error?) -> Void)?)
Expand All @@ -71,7 +71,7 @@ public protocol LocationManagerProtocol {
#endif
func requestLocation()

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
// MARK: - Monitoring Regions

func startMonitoring(for region: CLRegion)
Expand All @@ -80,12 +80,12 @@ public protocol LocationManagerProtocol {

// MARK: - Monitoring Visits

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
func startMonitoringVisits()
func stopMonitoringVisits()
#endif

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
// MARK: - Monitoring Significant Location Changes

func startMonitoringSignificantLocationChanges()
Expand All @@ -101,7 +101,7 @@ public protocol LocationManagerProtocol {

// MARK: - Beacon Ranging

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
func startRangingBeacons(satisfying constraint: CLBeaconIdentityConstraint)
func stopRangingBeacons(satisfying constraint: CLBeaconIdentityConstraint)
#endif
Expand Down
18 changes: 9 additions & 9 deletions Sources/SwiftLocation/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public final class Location {
/// Core Location configures the system to keep the app running to receive continuous background location updates,
/// and arranges to show the background location indicator (blue bar or pill) if needed.
/// Updates continue even if the app subsequently enters the background.
#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
public var allowsBackgroundLocationUpdates: Bool {
get { locationManager.allowsBackgroundLocationUpdates }
set { locationManager.allowsBackgroundLocationUpdates = newValue }
Expand All @@ -126,7 +126,7 @@ public final class Location {

// MARK: - Initialization

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
/// Initialize a new SwiftLocation instance to work with the Core Location service.
///
/// - Parameter locationManager: underlying service. By default the device's CLLocationManager instance is used
Expand Down Expand Up @@ -229,7 +229,7 @@ public final class Location {
switch permission {
case .whenInUse:
return try await requestWhenInUsePermission()
#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
case .always:
#if APPCLIP
return try await requestWhenInUsePermission()
Expand All @@ -252,7 +252,7 @@ public final class Location {

// MARK: - Monitor Location Updates

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
/// Start receiving changes of the locations with a stream.
///
/// - Returns: events received from the location manager.
Expand Down Expand Up @@ -305,7 +305,7 @@ public final class Location {
}
}

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
// MARK: - Monitor Regions

/// Starts the monitoring a region and receive stream of events from it.
Expand Down Expand Up @@ -336,7 +336,7 @@ public final class Location {

// MARK: - Monitor Visits Updates

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
/// Starts monitoring visits to locations.
///
/// - Returns: stream of events for visits.
Expand All @@ -359,7 +359,7 @@ public final class Location {
}
#endif

#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
// MARK: - Monitor Significant Locations

/// Starts monitoring significant location changes.
Expand Down Expand Up @@ -415,7 +415,7 @@ public final class Location {
///
/// - Parameter satisfying: A `CLBeaconIdentityConstraint` constraint.
/// - Returns: stream of events related to passed constraint.
#if !os(watchOS) && !os(tvOS)
#if !os(watchOS) && !os(tvOS) && !os(visionOS)
public func startRangingBeacons(satisfying: CLBeaconIdentityConstraint) async -> Tasks.BeaconMonitoring.Stream {
let task = Tasks.BeaconMonitoring(satisfying: satisfying)
return Tasks.BeaconMonitoring.Stream { stream in
Expand Down Expand Up @@ -466,7 +466,7 @@ public final class Location {
}
}

#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
/// Request authorization to get location both in foreground and background.
///
/// - Returns: authorization obtained.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/Support/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension CLLocationManager: LocationManagerProtocol {
/// - Parameter permission: permission you would to obtain.
public func validatePlistConfigurationOrThrow(permission: LocationPermission) throws {
switch permission {
#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
case .always:
if !Bundle.hasAlwaysAndWhenInUsePermission() {
throw LocationErrors.plistNotConfigured
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftLocation/Support/SupportModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public enum LocationAccuracy {

public enum LocationPermission {
/// Always authorization, both background and when in use.
#if !os(tvOS)
#if !os(tvOS) && !os(visionOS)
case always
#endif
/// Only when in use authorization.
Expand Down
Loading