Even after updating to 13.2.1 packages are not getting downloaded
Post
Replies
Boosts
Views
Activity
Just encountered this problem.
caused by a guard let unwrapping with the same name as a previous value in the same block, the compiler didn't identify the error.
example :
{
var mData : String? = Storage.value(key: "mValue")
guard let mData = mData else {return}
}
Same issue here xCode 12.3, mac os 11.1, M1
Pick your target, make sure the location updates is checked in the background modes.
First the location manager setup :
func setUp(){
Logger.log(classC: className, method: "setup", status: "Ok")
manager?.desiredAccuracy = kCLLocationAccuracyBestForNavigation
manager?.allowsBackgroundLocationUpdates = true
manager?.activityType = .otherNavigation
manager?.pausesLocationUpdatesAutomatically = false
manager?.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
}
Then use the geofencing to wake it up once and for all by updates it's monitoring. the '"regular one" and the geofencing one.
geofencing :
func monitorRegionAtLocation(identifier: String ) {
if CLLocationManager.isMonitoringAvailable(for: CLCircularRegion.self) {
let maxDistance = 100.0
guard let manager = manager else {return}
guard let location = manager.location else {return}
let coordinate2d = location.coordinate
let region = CLCircularRegion(center: coordinate2d,
radius: maxDistance, identifier: identifier)
region.notifyOnEntry = true
region.notifyOnExit = true
manager.startMonitoring(for: region)
}
}
regular :
Logger.log(classC: className, method: "startMonitoring", status: "Ok")
guard let manager = manager else {return}
manager.startUpdatingLocation()
manager.startMonitoringSignificantLocationChanges()
monitorRegionAtLocation(identifier: "Home")
}
geofencing callbacks :
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
startMonitoring()
lookUpCurrentLocation()
checkLastDateSent(method: "didEnterRegion")
}
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
startMonitoring()
lookUpCurrentLocation()
checkLastDateSent(method: "didExitRegion")
}
Here the method lookUpCurrentLocation() is using the location manger to require something, forcing it to stay awak while the app is currently dead .
example or lookUpCurrentLocation :
func lookUpCurrentLocation(){
Logger.log(classC: className, method: "lookUpCurrentLocation", status: "Ok")
guard let manager = manager else {
Logger.log(classC: className, method: "lookUpCurrentLocation", status: "location manager is null")
return
}
let lastLocation = manager.location
if let lastLocation = lastLocation {
currentLoc["accuracy"] = lastLocation.horizontalAccuracy
currentLoc["latitude"] = lastLocation.coordinate.latitude
currentLoc["longitude"] = lastLocation.coordinate.longitude
if let listener = listener {
listener.currentLocation(location : currentLoc )
}else{
Logger.log(classC: className, method: "lookUpCurrentLocation", status: "location listener is null")
}
}else{
Logger.log(classC: className, method: "lookUpCurrentLocation", status: "could not get last location")
}
}
Instead of loggers, you could schedule notifications to have a look at your location updates.
After your exit the geofencing zone for the first time the location arrow at the top of the screen will stay solid and you'' keep getting locations updates.