Please star the repository if you believe continuing the development of this package is worthwhile. This will help me understand which package deserves more effort.
This package uses Core Location under the hood to harness the power of GPS for accurate and efficient location tracking. By leveraging Swift’s async/await concurrency model, it provides a modern, clean, and scalable way to stream GPS data asynchronously. Core Location works with GPS, Wi-Fi, and cellular networks to determine a device’s position, ensuring both high accuracy and optimal performance.
Available for watchOS
if you are using the simulator don't forget to simulate locations
- Using new concurrency swift model around CoreLocation manager
- Extend API to allow customization of
CLLocationManager
- Support for iOS from 14.1 and watchOS from 7.0
- Seamless SwiftUI Integration Uses
@Published
properties for real-time UI updates or @observable is you can afford iOS17 or newer. - Streaming current location asynchronously
- Different strategies - Keep and publish all stack of locations since streaming has started or the last one
- Errors handling (as AsyncLocationErrors so CoreLocation errors CLError)
Background Updates
- Ensure the app has
location
included inUIBackgroundModes
for background updates to function.
@StateObject var service: LocationStreamer
For iOS 17+ and watchOS 10+, using @State macro:
@State var service: ObservableLocationStreamer
try await service.start()
Param | Description |
---|---|
strategy | Strategy for publishing locations. Default value is KeepLastStrategy. Another predefined option is KeepAllStrategy, or you can implement and test your own custom strategy by conforming to the LocationResultStrategy protocol. |
accuracy | The accuracy of a geographical coordinate. |
activityType | Constants indicating the type of activity associated with location updates. |
distanceFilter | A distance in meters from an existing location to trigger updates. |
backgroundUpdates | A Boolean value that indicates whether the app receives location updates when running in the background. |
or
Param | Description |
---|---|
strategy | Strategy for publishing locations. Default value is KeepLastStrategy. Another predefined option is KeepAllStrategy, or you can implement and test your own custom strategy by conforming to the LocationResultStrategy protocol. |
locationManager | A pre-configured CLLocationManager . |
- Product > Scheme > Edit Scheme
- Click Run .app
- Option tab
- Already checked Core Location > select your location
- Press OK
- You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
- Go to Product > Build Documentation or ⌃⇧⌘ D