Registry / type-stubs / pyobjc-framework-corelocation

pyobjc-framework-corelocation

JSON →
library12.2.2pypypiunverified

pyobjc-framework-corelocation provides Python wrappers for Apple's CoreLocation framework on macOS. It is part of the PyObjC project, a bidirectional bridge enabling Python scripts to interact with Objective-C libraries, including macOS Cocoa frameworks. This framework offers interfaces for obtaining a machine's physical location, allowing for geo-aware applications. The current version is 12.1 and it maintains an active release cadence, typically aligning with macOS SDK updates and Python version support.

pip install pyobjc-framework-corelocation
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-C
P
pyobjc-framework-corelocation
type-stubspythonv12.2.2
Install
—
Import
—
Disk
—
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CoreLocation
✓ import CoreLocation
Classes and functions within the CoreLocation framework are then accessed as attributes of the imported module (e.g., CoreLocation.CLLocationManager).

This quickstart demonstrates how to perform forward geocoding using `CLGeocoder` from the `CoreLocation` framework. It shows the typical PyObjC pattern of initializing Objective-C objects, setting up a Python delegate to handle asynchronous callbacks, and running a `NSRunLoop` to process events until the operation completes. Note that CoreLocation APIs require network access for geocoding and user permission prompts on macOS.

import objc from CoreLocation import CLGeocoder from Foundation import NSRunLoop, NSDate, NSObject import time class GeocoderDelegate(NSObject): # This is a delegate class to handle geocoding results asynchronously. # In a real application, you might use a more robust threading/event loop setup. def init(self): self = super(GeocoderDelegate, self).init() if not self: return None self.results = {"placemarks": [], "error": None} self.completed = False return self def geocoder_didGeocodePlacemarks_error_(self, geocoder, placemarks, error): if error: self.results["error"] = error.localizedDescription() elif placemarks: self.results["placemarks"] = placemarks self.completed = True def forward_geocode(address: str) -> list[dict]: with objc.autorelease_pool(): geocoder = CLGeocoder.alloc().init() delegate = GeocoderDelegate.alloc().init() # Call the Objective-C method with a Python delegate geocoder.geocodeAddressString_completionHandler_(address, lambda placemarks, error: delegate.geocoder_didGeocodePlacemarks_error_(geocoder, placemarks, error)) # Keep the runloop active until the geocoding is complete # This is a blocking loop for demonstration; for GUI apps, the main runloop handles this. timeout = time.time() + 10 # 10-second timeout while not delegate.completed and time.time() < timeout: NSRunLoop.currentRunLoop().runMode_beforeDate_( "NSDefaultRunLoopMode", NSDate.dateWithTimeIntervalSinceNow_(0.1) ) if not delegate.completed: raise TimeoutError("Geocoding request timed out.") if delegate.results["error"]: raise Exception(f"Geocoding error: {delegate.results['error']}") formatted_results = [] for pm in delegate.results["placemarks"]: loc = pm.location() if loc: coord = loc.coordinate() formatted_results.append({ "latitude": coord.latitude, "longitude": coord.longitude, "name": pm.name(), "locality": pm.locality(), "country": pm.country() }) return formatted_results if __name__ == "__main__": try: locations = forward_geocode("1 Infinite Loop, Cupertino, CA") if locations: print("\nLocation found:") for loc in locations: for key, value in loc.items(): if value: print(f" {key}: {value}") else: print("No locations found.") except Exception as e: print(f"Error: {e}")
Debug
Known issues
breakingPyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped Python 3.8. Ensure your Python version is compatible with the PyObjC version you are installing.
fix
Upgrade your Python environment to Python 3.10 or later for PyObjC 12.x. Always check `requires_python` on PyPI or the PyObjC changelog for specific version requirements.
affects: 11.0, 12.0
breakingPyObjC 11.1 changed how initializer methods (`init` family) are modeled, now correctly reflecting that they 'steal' a reference to `self` and return a new one, as per clang's ARC documentation. This affects object lifecycle and reference counting.
fix
Review code that interacts with object initialization, especially custom subclasses or factory methods, to ensure correct reference handling. Explicit memory management is rarely needed in Python, but understanding the underlying Objective-C semantics is crucial for correct behavior.
affects: >=11.1
gotchaPyObjC is a macOS-specific library and will not install or run on other operating systems. The frameworks it wraps (like CoreLocation) are Apple-proprietary and only available on macOS.
fix
Only use `pyobjc-framework-corelocation` in macOS environments. Attempting to install or run on Windows/Linux will result in errors.
affects: all
gotchaUnlike Objective-C, where sending a message to `nil` (equivalent to Python `None`) is a no-op, attempting to call a method on a Python `None` object (which PyObjC translates from `nil`) will raise an `AttributeError`.
fix
Always check for `None` before calling methods on PyObjC-wrapped objects that might originate from Objective-C `nil` values. E.g., `if my_obj is not None: my_obj.doSomething_()`.
affects: all
gotchaCoreLocation services require specific user permissions and proper binary signing on macOS. Unsigned or ad-hoc signed applications may not be able to access location data, and users will be prompted for permission upon first access.
fix
Ensure your macOS application bundle is properly signed. Handle user permission requests gracefully in your application logic. Location services may not function as expected in scripts run directly without a proper application context.
affects: all
gotchaCoreLocation delegate methods are invoked on the `NSRunLoop` of the thread where the `CLLocationManager` object was initialized. If you are not in a GUI application's main thread, you must explicitly run a `NSRunLoop` for delegate callbacks to be processed.
fix
For console applications or background threads, ensure you start and periodically run `NSRunLoop.currentRunLoop().runMode_beforeDate_()` to allow CoreLocation to deliver updates to your delegate.
affects: all
Upgrade
Version history
12.2.2latest on PyPI · released Aug 11, 2026
Audit
Dependencies
pyobjc-corerequiredCore component of the PyObjC bridge, providing fundamental Python-Objective-C interoperability.
pyobjc-framework-cocoarequiredProvides core Cocoa framework bindings often implicitly relied upon by other frameworks for fundamental Objective-C classes (e.g., Foundation.NSRunLoop).
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
2
Resources
pyobjc-framework-corelocation — pip install pyobjc-framework-corelocation · libregistry