Skip to content

Commit

Permalink
Allow adding to iOS 13 project (though GeoMonitor remains iOS 14+) (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk authored Jan 26, 2023
1 parent 4e45574 commit 03f3cab
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/build
/build

# Running tests
TestResults
TestResults.xcresult
4 changes: 2 additions & 2 deletions GeoMonitor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions Sources/GeoMonitor/GeoMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
import CoreLocation
import MapKit

@available(iOS 14.0, *)
public protocol GeoMonitorDataSource {
func fetchRegions(trigger: GeoMonitor.FetchTrigger) async -> [CLCircularRegion]
}
Expand All @@ -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
Expand Down Expand Up @@ -333,6 +335,7 @@ public class GeoMonitor: NSObject, ObservableObject {

// MARK: - Trigger on move

@available(iOS 14.0, *)
extension GeoMonitor {

@discardableResult
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -471,6 +475,7 @@ extension GeoMonitor {

// MARK: - CLLocationManagerDelegate

@available(iOS 14.0, *)
extension GeoMonitor: CLLocationManagerDelegate {

public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
Expand Down Expand Up @@ -603,6 +608,7 @@ extension GeoMonitor: CLLocationManagerDelegate {

// MARK: - Helpers

@available(iOS 14.0, *)
private struct SimpleDataSource: GeoMonitorDataSource {
let handler: (GeoMonitor.FetchTrigger) async -> [CLCircularRegion]

Expand Down
1 change: 1 addition & 0 deletions Tests/GeoMonitorTests/GeoMonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 03f3cab

Please sign in to comment.