{"id":6092,"library":"pyobjc-framework-cryptotokenkit","title":"PyObjC CryptoTokenKit Framework","description":"PyObjC is a comprehensive bridge between Python and Objective-C, enabling the development of full-featured Cocoa applications entirely in Python. This specific package provides Python wrappers for Apple's CryptoTokenKit framework on macOS, allowing Python applications to interact with cryptographic tokens like smart cards and Hardware Security Modules (HSMs). The current version is 12.1, with releases typically aligning with macOS SDK updates and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","cryptography","framework","objective-c","bindings","apple"],"install":[{"cmd":"pip install pyobjc-framework-cryptotokenkit","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"This package provides the core bridging functionality between Python and Objective-C, essential for all PyObjC framework wrappers.","package":"pyobjc-core"}],"imports":[{"note":"Framework bindings are accessed directly by importing the framework name as a Python package.","symbol":"CryptoTokenKit","correct":"import CryptoTokenKit"},{"note":"Classes within the framework are accessed as attributes of the imported framework module.","symbol":"TKTokenDriver","correct":"from CryptoTokenKit import TKTokenDriver"}],"quickstart":{"code":"import CryptoTokenKit\n\n# Accessing a class from the CryptoTokenKit framework\n# Note: Instantiating many CryptoTokenKit classes directly in a script\n# without being a proper macOS token extension might not be meaningful.\n# This example primarily demonstrates successful import and class access.\n\ntoken_driver_class = CryptoTokenKit.TKTokenDriver\n\nprint(f\"Successfully imported CryptoTokenKit.\")\nprint(f\"TKTokenDriver is a: {type(token_driver_class)}\")\nprint(f\"Name of the TKTokenDriver class: {token_driver_class.__name__}\")\n\n# Example of attempting to access a class method (if available)\n# (This specific call might not be functional without a running token service)\n# if hasattr(token_driver_class, 'driverExtensionPointForIdentifier_'):\n#     print(f\"TKTokenDriver has driverExtensionPointForIdentifier_ method.\")","lang":"python","description":"This quickstart demonstrates how to import the `CryptoTokenKit` framework and access one of its core classes, `TKTokenDriver`. While many classes in `CryptoTokenKit` are meant to be used within macOS app extensions for cryptographic token management, this snippet validates that the PyObjC bindings are correctly installed and accessible."},"warnings":[{"fix":"Upgrade to Python 3.10 or later, or pin `pyobjc-framework-cryptotokenkit` to `<12.0`.","message":"PyObjC 12.0 dropped support for Python 3.9. Users on Python 3.9 must use an older version of PyObjC.","severity":"breaking","affected_versions":">=12.0"},{"fix":"Upgrade to Python 3.9 or later, or pin `pyobjc-framework-cryptotokenkit` to `<11.0`.","message":"PyObjC 11.0 dropped support for Python 3.8. Users on Python 3.8 must use an older version of PyObjC.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Review Python implementations of Objective-C 'init' methods to ensure correct reference counting, especially if manual memory management was previously assumed or if issues with object lifecycle occur.","message":"PyObjC 11.1 aligned its behavior for Objective-C 'init' family methods with `clang`'s automatic reference counting documentation. This means that methods in the 'init' family now correctly steal a reference to `self` and return a new reference, which may affect custom initializers written in Python.","severity":"gotcha","affected_versions":">=11.1"},{"fix":"If encountering issues with object initialization, especially when subclassing Objective-C classes in Python and using custom `__new__` or `__init__`, consult the 10.3.1 release notes and adapt your object creation pattern.","message":"The interaction between Python's `__init__` and `__new__` methods changed in PyObjC 10.3, where `__init__` could not be used with PyObjC-provided `__new__`. A partial reintroduction in v10.3.1 allowed `__init__` when a user implements `__new__`, but not when relying on PyObjC's `__new__`.","severity":"gotcha","affected_versions":"10.3, 10.3.1"},{"fix":"Avoid using PyObjC in contexts that heavily rely on Python's experimental free-threading, or thoroughly test your application in such environments and report any issues.","message":"While PyObjC 11.0 and 10.3 include experimental support for free-threading (PEP 703) introduced in Python 3.13, it does not fully support this feature. Users should be aware of potential limitations or issues when running PyObjC with a free-threaded Python interpreter.","severity":"gotcha","affected_versions":">=10.3 (with Python 3.13+)"},{"fix":"Update code that relies on `objc.ObjCLazyModule` or expects `objc` as an attribute of framework binding packages. Access symbols directly from the framework package (e.g., `Foundation.NSString` instead of `Foundation.objc.NSString`).","message":"`objc.ObjCLazyModule` is deprecated. The lazy loading mechanism now defaults to using module-level `__dir__` and `__getattr__`. This changes how attributes are accessed and ensures private symbols from dependencies are no longer implicitly imported.","severity":"deprecated","affected_versions":">=10.0"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}