Skip to content

fix(macos): resolve deprecated authorizationStatus warnings in geolocator_apple#1773

Open
Tinnci wants to merge 3 commits intoBaseflow:mainfrom
Tinnci:fix/macos-deprecated-authorization-status
Open

fix(macos): resolve deprecated authorizationStatus warnings in geolocator_apple#1773
Tinnci wants to merge 3 commits intoBaseflow:mainfrom
Tinnci:fix/macos-deprecated-authorization-status

Conversation

@Tinnci
Copy link

@Tinnci Tinnci commented Mar 12, 2026

Summary

Fixes deprecated CLLocationManager.authorizationStatus warnings on macOS 11+ builds in geolocator_apple.

Problem

When building for macOS, Xcode emits deprecation warnings:

'authorizationStatus' was deprecated in macOS 11.0

There are two call sites in PermissionHandler.m:

  1. checkPermission (line ~42): The else branch of an @available(iOS 14, macOS 11, *) check calls the deprecated class method [CLLocationManager authorizationStatus]. This is correct behavior for older OS versions but triggers a warning on modern SDKs.

  2. requestPermission:errorHandler: (line ~53): Uses CLLocationManager.authorizationStatus without any @available guard.

See #1732.

Solution

  1. checkPermission: Wrap the deprecated call in #pragma clang diagnostic push/ignored/pop to suppress the warning in the else branch, since we already know we're on an older OS version at that point.

  2. requestPermission:errorHandler:: Replace the unguarded CLLocationManager.authorizationStatus with [self checkPermission], which already has the proper @available guard and returns the same CLAuthorizationStatus value.

Testing

  • No behavioral change — the same authorization status values are returned
  • Eliminates all macOS deprecation warnings from PermissionHandler.m

Closes #1732

1. checkPermission: suppress deprecation warning in else-branch with
   #pragma clang diagnostic, since CLLocationManager.authorizationStatus
   (class method) is only called on iOS < 14 / macOS < 11.

2. requestPermission: replace unguarded CLLocationManager.authorizationStatus
   with [self checkPermission] which already has the @available guard.

Closes Baseflow#1732
Copilot AI review requested due to automatic review settings March 12, 2026 03:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the iOS/macOS permission handling in geolocator_apple to use the iOS 14+/macOS 11+ instance-based authorization status API and to silence deprecation warnings when falling back to the legacy class method.

Changes:

  • Wraps the legacy [CLLocationManager authorizationStatus] call with clang diagnostic pragmas to suppress deprecation warnings.
  • Updates requestPermission to use the shared checkPermission helper for determining current authorization status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Tinnci added 2 commits March 12, 2026 11:47
Add the new locationManagerDidChangeAuthorization: delegate method
(available iOS 14+ / macOS 11+) to both PermissionHandler and
LocationServiceStreamHandler.

Keep the old didChangeAuthorizationStatus: method for backward
compatibility with iOS < 14 / macOS < 11, suppressing the
-Wdeprecated-implementations warning with #pragma.

Extract _notifyServiceStatus helper in LocationServiceStreamHandler
to avoid duplicating the dispatch logic.
Restore the direct class method call CLLocationManager.authorizationStatus
with #pragma suppression in requestPermission, so the early-return path
does not trigger getLocationManager to lazily create and retain a manager.

Address Copilot review comment on lines 49-51.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Multiple warnings on Macos of Deprecated APIs

2 participants