Skip to content

Core Location Diagnostics

Systematic Core Location troubleshooting for location failures, background issues, authorization problems, and geofence debugging.

Overview

Diagnostic workflows for debugging Core Location using CLLocationUpdate (iOS 17+) and CLMonitor (iOS 17+). Includes systematic troubleshooting, decision trees, and common mistake patterns.

Example Prompts

Questions you can ask Claude that will invoke this diagnostic:

  • "Why aren't my location updates arriving?"
  • "Location stops working when my app goes to background"
  • "Users are always denying location permission"
  • "My geofence events never fire"
  • "The location arrow icon won't go away"
  • "How do I debug CLMonitor not triggering?"

Symptoms This Diagnoses

Location Update Issues

  • Updates never arrive — authorization, Info.plist, iteration
  • Location unavailable — indoor, airplane mode, GPS lock
  • Accuracy unexpectedly poor — reduced accuracy, configuration
  • Updates stop randomly — Task cancellation, isStationary

Background Location Issues

  • Stops when backgrounded — capability, session, authorization
  • Doesn't resume after suspend — session recovery, relaunch
  • Blue indicator missing — session not held, wrong setup

Authorization Problems

  • Always denied on fresh install — Info.plist strings
  • insufficientlyInUse — requesting from background
  • Reduced accuracy forced — user choice, temporary override

Geofencing Issues

  • Events not triggering — condition limit, radius too small
  • Stale lastEvent — not awaiting events
  • Monitor not persisting — not reinitializing on launch

When to Use This Diagnostic

Use this diagnostic when:

  • Location updates never arrive
  • Background location stops working
  • Users always deny authorization
  • Location accuracy is unexpectedly poor
  • Geofence events don't trigger
  • Location icon won't go away

Diagnostic Workflow

1. Check Authorization (2 min)
   ├─ authorizationStatus value
   ├─ locationServicesEnabled()
   ├─ accuracyAuthorization
   └─ Info.plist keys present

2. Verify Iteration (2 min)
   ├─ Task actually running
   ├─ Not cancelled prematurely
   ├─ Stored in property (not local)
   └─ Awaiting updates

3. Check Background Setup (5 min)
   ├─ Background mode capability
   ├─ CLBackgroundActivitySession held
   ├─ Session started from foreground
   └─ Recovery on relaunch

4. Inspect Diagnostic Properties (3 min)
   ├─ update.authorizationDenied
   ├─ update.locationUnavailable
   ├─ update.accuracyLimited
   └─ update.isStationary

Diagnostic Patterns

Pattern 1: No Location Updates

Symptom: for try await update in CLLocationUpdate.liveUpdates() never yields Diagnosis: Check authorizationStatus and Info.plist Fix: Add NSLocationWhenInUseUsageDescription, request authorization

Pattern 2: Background Stops Working

Symptom: Updates stop when app backgrounded Diagnosis: Missing CLBackgroundActivitySession or background mode Fix: Add capability, hold session in property (not local variable)

Pattern 3: Geofence Never Triggers

Symptom: CLMonitor events never fire Diagnosis: At 20-condition limit, radius < 100m, or not awaiting events Fix: Check condition count, increase radius, ensure Task awaits events

Pattern 4: Authorization Always Denied

Symptom: Fresh install immediately denied Diagnosis: Missing or empty Info.plist usage strings Fix: Add compelling NSLocationWhenInUseUsageDescription

Pattern 5: Location Icon Persists

Symptom: Arrow icon stays after feature done Diagnosis: Task not cancelled, session not invalidated, or CLMonitor still active Fix: Cancel Task, invalidate session, remove conditions

Quick Reference

SymptomCheck FirstCommon Fix
No updatesauthorizationStatusAdd Info.plist key
Background stopsBackground modeAdd capability + session
Always deniedInfo.plist stringsWrite compelling reason
Poor accuracyaccuracyAuthorizationRequest temporary full
Geofence silentcondition countStay under 20
Icon persistsTask/session stateCancel/invalidate

Documentation Scope

This is a diagnostic skill — systematic troubleshooting workflows for Core Location issues.

Diagnostic includes

  • 6 symptom-based decision trees
  • 5 common mistake patterns with fixes
  • Quick reference table for fast diagnosis
  • Console debugging commands

Vs Reference: Diagnostic skills provide symptom-based troubleshooting. Reference skills provide comprehensive API information.

Resources

WWDC: 2023-10180, 2023-10147, 2024-10212

Docs: /corelocation, /corelocation/clmonitor, /corelocation/cllocationupdate

Released under the MIT License