A library that bridges the Composable Architecture and Core Location. Largely based on pointfreeco/composable-core-location but works with the Composable Architecture v1.15.0.
Currently the library only supports the most basic functionality for a hobby project I am working on. If you need more functionality, please feel free to submit a PR. This library has not been thorougly tested.
import ComposableArchitecture
import ComposableCoreLocation
@Reducer
struct MyReducer {
struct State: Equatable {}
enum Action: Equateable {
case onAppear
}
@Dependency(\.locationManagerClient) var locationManagerClient
var body: some Reducer<State, Action> {
Reduce { state, action in
switch action {
case .onAppear:
locationManagerClient.requestWhenInUseAuthorization()
return .run { send in
for await delegateAction in await locationManagerClient.delegate() {
switch delegateAction {
case .didChangeAuthorization(let status):
// handle authorization changes with other effects
case .didUpdateLocations(let locations):
// handle location updates with other effects
}
}
}
}
}
}
}
Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/drewalth/composable-core-location.git", from: "0.0.1")
]
Check for the latest release tag
Navigate to File -> Swift Packages -> Add Package Dependency...
and enter the repo URL:
https://github.com/drewalth/composable-core-location.git
Be sure to add the following keys to your Info.plist
file:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires access to your location to provide location-based features.</string>
<key>NSLocationUsageDescription</key>
<string>This app requires access to your location to provide location-based features.</string>
- Add remaining
CLLocationManagerDelegate
methods - Add Swift 6 support
- Add tests
- Add automatic semantic versioning
- Add GitHub Action for CI/CD (testing, build, versioning, etc.)
- Make better
Any and all contributions are welcome! Please feel free to submit a Pull Request.