Registry / auth-security / pyobjc-framework-devicecheck

pyobjc-framework-devicecheck

JSON →
library12.2pypypiunverified

PyObjC-framework-DeviceCheck provides Python wrappers for Apple's DeviceCheck framework on macOS, allowing Python applications to interact with DeviceCheck APIs to manage device state and assert app integrity. It is part of the broader PyObjC project, a bridge that enables Python scripts to fully utilize Objective-C class libraries like Cocoa. The library is actively maintained, with version 12.1 being the current release, and follows a frequent release cadence tied to macOS SDK and Python version updates.

pip install pyobjc-framework-devicecheck
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-D
P
pyobjc-framework-devicecheck
auth-securitypythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.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.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

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

DCDevice
from DeviceCheck import DCDevice
Classes and functions from Objective-C frameworks are mapped directly to Python modules with the same name.
AppHelper
from PyObjCTools import AppHelper
Required for running event loops in command-line scripts for asynchronous Objective-C calls.

This quickstart demonstrates how to access the current DCDevice, check if DeviceCheck is supported, and then generate a device token using an asynchronous Objective-C method. A Python function is used as the completion handler to process the token or any errors, and the PyObjCTools.AppHelper is used to manage the event loop necessary for asynchronous Objective-C calls in a script.

import objc from DeviceCheck import DCDevice from PyObjCTools import AppHelper import Foundation # For NSData, NSError types def device_check_completion_handler(token_data, error): """Objective-C completion handler for generateTokenWithCompletionHandler_.""" if error: print(f"Error generating token: {error.localizedDescription()}") elif token_data: # NSData object from Objective-C can be converted to Python bytes python_token = token_data.bytes().tobytes() print(f"Successfully generated DeviceCheck token (first 10 bytes): {python_token[:10]}...") else: print("No token data and no error received.") AppHelper.stopEventLoop() def main(): device = DCDevice.currentDevice() if not device.isSupported(): print("DeviceCheck is not supported on this device (e.g., simulator).") return print("DeviceCheck is supported. Generating token...") # Call the asynchronous Objective-C method with a Python callable as handler device.generateTokenWithCompletionHandler_(device_check_completion_handler) # Start the PyObjC event loop to process the asynchronous call print("Starting event loop (waiting for token or error)...") AppHelper.runEventLoop() print("Event loop stopped.") if __name__ == "__main__": main()
Debug
Known issues
breakingPyObjC has dropped support for older Python versions. Version 12.0 removed support for Python 3.9, and version 11.0 removed support for Python 3.8. Users must ensure their Python environment meets the `>=3.10` requirement for PyObjC 12.1.
fix
Upgrade Python to version 3.10 or later. Consider using a virtual environment to manage Python versions.
affects: >=11.0
breakingPyObjC 11.1 changed how it models Objective-C's Automatic Reference Counting (ARC) for 'init' methods. Methods in the 'init' family now correctly 'steal a reference to self and return a new reference' in alignment with `clang`'s documentation. This change can affect applications relying on the previous, less accurate reference counting behavior, especially for singletons or in multithreaded contexts.
fix
Review custom Objective-C classes used with PyObjC, particularly those with 'init' methods, to ensure they correctly handle reference counts according to ARC guidelines. Update code that might have implicitly relied on previous PyObjC reference count handling quirks.
affects: >=11.1
gotchaThe `DeviceCheck` framework, and thus `pyobjc-framework-devicecheck`, only functions on physical macOS/iOS devices and will not work when run on a simulator. Calls to `DCDevice.currentDevice().isSupported()` will return `False` on simulators.
fix
Test DeviceCheck functionality exclusively on actual hardware to ensure proper behavior and avoid unexpected `isSupported()` return values.
affects: All
gotchaSubclassing `NSString` or `NSMutableString` in Python using PyObjC is not supported and will lead to application crashes. These classes are treated as 'final' within the PyObjC bridge due to special internal handling.
fix
Avoid subclassing `NSString` or `NSMutableString` directly. If string manipulation or custom string behavior is required, consider wrapping standard Python strings or using other Cocoa collection types.
affects: All
gotchaSpecific `NSData` and `NSMutableData` initialization methods, such as `dataWithBytesNoCopy:length:` or `initWithBytesNoCopy:length:`, should not be used with Python buffers. Cocoa might attempt to `free()` the buffer when the `NSData` object is released, which is incompatible with Python's memory management and can cause crashes. For methods like `dataWithBytesNoCopy:length:freeWhenDone:`, the `freeWhenDone` argument *must* be `False`.
fix
Always use `buffer(value)` to safely bridge Python bytes-like objects to `NSData` subclasses. If you must use methods that take `bytesNoCopy`, ensure the `freeWhenDone` parameter is explicitly set to `False`.
affects: All
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides the core bridge between Python and Objective-C, essential for all PyObjC framework wrappers.
Agent activity
46 hits · last 30 days
node
42
OpenAI (training)
1
Resources
pyobjc-framework-devicecheck — pip install pyobjc-framework-devicecheck · libregistry