Avoid Max Location Accuracy

ID

swift.avoid_max_location_accuracy

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Efficiency

Language

Swift

Tags

battery, efficiency, ios

Description

Reports references to the Core Location desired-accuracy constants kCLLocationAccuracyBest and kCLLocationAccuracyBestForNavigation. These force the device into its highest-precision GPS mode and drain battery quickly.

manager.desiredAccuracy = kCLLocationAccuracyBest                  // FLAW
manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation     // FLAW

manager.desiredAccuracy = kCLLocationAccuracyHundredMeters         // OK
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters      // OK

Rationale

Setting desiredAccuracy to kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation engages the GPS chip in its highest-precision mode (sub-metre, multi-constellation, sensor fusion with the IMU). These modes are appropriate for turn-by-turn navigation and fitness tracking but waste battery for use cases like nearby search, weather, geofencing, or coarse analytics — where ±100 m is plenty. Apps that needlessly request maximum accuracy show up prominently in the iOS battery usage chart, and users disable location permissions in response.

Remediation

Pick the coarsest accuracy that still satisfies the feature:

// "Around here" use cases — search, weather
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters

// Geofences, store finders
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters

// Significant-change monitoring — minimal battery impact
manager.startMonitoringSignificantLocationChanges()

Reserve kCLLocationAccuracyBest and kCLLocationAccuracyBestForNavigation for active turn-by-turn or real-time tracking screens, and revert to a coarser value as soon as the screen is dismissed.