Allow adding to iOS 13 project (though GeoMonitor remains iOS 14+) (#4)

This commit is contained in:
Adrian Schönig 2023-01-27 09:30:49 +11:00 committed by GitHub
parent 4e455745e6
commit 03f3cab0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 4 deletions

6
.gitignore vendored
View File

@ -7,4 +7,8 @@ DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/build
/build
# Running tests
TestResults
TestResults.xcresult

View File

@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#
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"
# 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, "14.0"
spec.platform = :ios, "13.0"
# When using multiple platforms
# spec.ios.deployment_target = "5.0"

View File

@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "GeoMonitor",
platforms: [
.iOS(.v14)
.iOS(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -17,6 +17,8 @@ Relies on a mixture of techniques, such as:
## Usage
*GeoMonitor requires iOS 14+*
```swift
self.monitor = GeoMonitor {
// Fetch the latest regions; also called when entering one.

View File

@ -3,6 +3,7 @@ import Foundation
import CoreLocation
import MapKit
@available(iOS 14.0, *)
public protocol GeoMonitorDataSource {
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.
/// - 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)
@available(iOS 14.0, *)
public class GeoMonitor: NSObject, ObservableObject {
enum Constants {
static var currentLocationRegionMaximumRadius: CLLocationDistance = 2_500
@ -333,6 +335,7 @@ public class GeoMonitor: NSObject, ObservableObject {
// MARK: - Trigger on move
@available(iOS 14.0, *)
extension GeoMonitor {
@discardableResult
@ -388,6 +391,7 @@ extension GeoMonitor {
// MARK: - Alert monitoring logic
@available(iOS 14.0, *)
extension GeoMonitor {
private func monitorDebounced(_ regions: [CLCircularRegion], location: CLLocation?, delay: TimeInterval? = nil) {
@ -471,6 +475,7 @@ extension GeoMonitor {
// MARK: - CLLocationManagerDelegate
@available(iOS 14.0, *)
extension GeoMonitor: CLLocationManagerDelegate {
public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
@ -603,6 +608,7 @@ extension GeoMonitor: CLLocationManagerDelegate {
// MARK: - Helpers
@available(iOS 14.0, *)
private struct SimpleDataSource: GeoMonitorDataSource {
let handler: (GeoMonitor.FetchTrigger) async -> [CLCircularRegion]

View File

@ -3,6 +3,7 @@ import CoreLocation
@testable import GeoMonitor
@available(iOS 14.0, *)
final class GeoMonitorTests: XCTestCase {
func testManyRegions() throws {
// This is an example of a functional test case.