PyObjC is a bridge between Python and the Objective-C runtime, allowing Python scripts to interact with macOS frameworks. `pyobjc-framework-datadetection` provides Python bindings for the DataDetection framework on macOS, enabling programmatic detection of data such as phone numbers, dates, and addresses in text. The current version is 12.1, with releases typically aligning with new macOS SDKs and Python versions.
pip install pyobjc-framework-datadetectionVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `DDScanner` to detect phone numbers, dates, and email addresses in a given string. It combines multiple detection conditions using the bitwise OR operator (`|`) and then iterates through the `DDScannerResult` objects to extract matched strings and their specific values.
Upgrade Python to 3.10 or later, or use an older PyObjC version compatible with your Python environment.
Carefully review custom PyObjC class implementations, especially those overriding `__new__`, to ensure `__init__` is called correctly. Refer to the PyObjC 10.3 and 10.3.1 release notes for details.
Understand ARC principles when working with PyObjC `init` methods, especially when manually managing object references or subclassing Objective-C classes in Python. Most common usage patterns are unaffected.
Avoid using PyObjC in a free-threaded Python 3.13 environment unless absolutely necessary and after thorough testing. Stick to regular Python threading models for stability.
Upgrade to PyObjC 10.1 or later to enable `os.fspath()` compatibility with Cocoa URLs for local filesystem paths. For older versions, convert URLs to Python strings manually using appropriate PyObjC wrappers.