Allow adding to iOS 13 project (though GeoMonitor remains iOS 14+) (#4)
This commit is contained in:
parent
4e455745e6
commit
03f3cab0ee
|
@ -8,3 +8,7 @@ DerivedData/
|
||||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
.netrc
|
.netrc
|
||||||
/build
|
/build
|
||||||
|
|
||||||
|
# Running tests
|
||||||
|
TestResults
|
||||||
|
TestResults.xcresult
|
|
@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
|
||||||
#
|
#
|
||||||
|
|
||||||
spec.name = "GeoMonitor"
|
spec.name = "GeoMonitor"
|
||||||
spec.version = "0.1.1"
|
spec.version = "0.1.2"
|
||||||
spec.summary = "iOS library for background monitoring of a user's movement"
|
spec.summary = "iOS library for background monitoring of a user's movement"
|
||||||
|
|
||||||
# This description is used to generate tags and improve search results.
|
# This description is used to generate tags and improve search results.
|
||||||
|
@ -67,7 +67,7 @@ Pod::Spec.new do |spec|
|
||||||
#
|
#
|
||||||
|
|
||||||
# spec.platform = :ios
|
# spec.platform = :ios
|
||||||
spec.platform = :ios, "14.0"
|
spec.platform = :ios, "13.0"
|
||||||
|
|
||||||
# When using multiple platforms
|
# When using multiple platforms
|
||||||
# spec.ios.deployment_target = "5.0"
|
# spec.ios.deployment_target = "5.0"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import PackageDescription
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "GeoMonitor",
|
name: "GeoMonitor",
|
||||||
platforms: [
|
platforms: [
|
||||||
.iOS(.v14)
|
.iOS(.v13)
|
||||||
],
|
],
|
||||||
products: [
|
products: [
|
||||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||||
|
|
|
@ -17,6 +17,8 @@ Relies on a mixture of techniques, such as:
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
*GeoMonitor requires iOS 14+*
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
self.monitor = GeoMonitor {
|
self.monitor = GeoMonitor {
|
||||||
// Fetch the latest regions; also called when entering one.
|
// Fetch the latest regions; also called when entering one.
|
||||||
|
|
|
@ -3,6 +3,7 @@ import Foundation
|
||||||
import CoreLocation
|
import CoreLocation
|
||||||
import MapKit
|
import MapKit
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
public protocol GeoMonitorDataSource {
|
public protocol GeoMonitorDataSource {
|
||||||
func fetchRegions(trigger: GeoMonitor.FetchTrigger) async -> [CLCircularRegion]
|
func fetchRegions(trigger: GeoMonitor.FetchTrigger) async -> [CLCircularRegion]
|
||||||
}
|
}
|
||||||
|
@ -16,6 +17,7 @@ public protocol GeoMonitorDataSource {
|
||||||
/// alerted, when they get to them (e.g., traffic incidents); where monitoring can be long-term.
|
/// alerted, when they get to them (e.g., traffic incidents); where monitoring can be long-term.
|
||||||
/// - Monitoring a set of regions where the user wants to be alerted as they approach them, but
|
/// - Monitoring a set of regions where the user wants to be alerted as they approach them, but
|
||||||
/// monitoring is limited for brief durations (e.g., "get off here" alerts for transit apps)
|
/// monitoring is limited for brief durations (e.g., "get off here" alerts for transit apps)
|
||||||
|
@available(iOS 14.0, *)
|
||||||
public class GeoMonitor: NSObject, ObservableObject {
|
public class GeoMonitor: NSObject, ObservableObject {
|
||||||
enum Constants {
|
enum Constants {
|
||||||
static var currentLocationRegionMaximumRadius: CLLocationDistance = 2_500
|
static var currentLocationRegionMaximumRadius: CLLocationDistance = 2_500
|
||||||
|
@ -333,6 +335,7 @@ public class GeoMonitor: NSObject, ObservableObject {
|
||||||
|
|
||||||
// MARK: - Trigger on move
|
// MARK: - Trigger on move
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
extension GeoMonitor {
|
extension GeoMonitor {
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
|
@ -388,6 +391,7 @@ extension GeoMonitor {
|
||||||
|
|
||||||
// MARK: - Alert monitoring logic
|
// MARK: - Alert monitoring logic
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
extension GeoMonitor {
|
extension GeoMonitor {
|
||||||
|
|
||||||
private func monitorDebounced(_ regions: [CLCircularRegion], location: CLLocation?, delay: TimeInterval? = nil) {
|
private func monitorDebounced(_ regions: [CLCircularRegion], location: CLLocation?, delay: TimeInterval? = nil) {
|
||||||
|
@ -471,6 +475,7 @@ extension GeoMonitor {
|
||||||
|
|
||||||
// MARK: - CLLocationManagerDelegate
|
// MARK: - CLLocationManagerDelegate
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
extension GeoMonitor: CLLocationManagerDelegate {
|
extension GeoMonitor: CLLocationManagerDelegate {
|
||||||
|
|
||||||
public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
|
public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
|
||||||
|
@ -603,6 +608,7 @@ extension GeoMonitor: CLLocationManagerDelegate {
|
||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
private struct SimpleDataSource: GeoMonitorDataSource {
|
private struct SimpleDataSource: GeoMonitorDataSource {
|
||||||
let handler: (GeoMonitor.FetchTrigger) async -> [CLCircularRegion]
|
let handler: (GeoMonitor.FetchTrigger) async -> [CLCircularRegion]
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import CoreLocation
|
||||||
|
|
||||||
@testable import GeoMonitor
|
@testable import GeoMonitor
|
||||||
|
|
||||||
|
@available(iOS 14.0, *)
|
||||||
final class GeoMonitorTests: XCTestCase {
|
final class GeoMonitorTests: XCTestCase {
|
||||||
func testManyRegions() throws {
|
func testManyRegions() throws {
|
||||||
// This is an example of a functional test case.
|
// This is an example of a functional test case.
|
||||||
|
|
Loading…
Reference in New Issue