{"library":"pyobjc-framework-adservices","title":"PyObjC AdServices Framework","description":"PyObjC provides Python wrappers for the \"AdServices\" framework on macOS, allowing Python scripts to interact with Apple's Objective-C APIs for ad attribution. This specific package, `pyobjc-framework-adservices`, enables access to the AdServices framework. PyObjC is actively maintained with frequent releases, often synchronized with macOS SDK updates, ensuring compatibility with the latest Apple operating systems and developer tools. The current version is 12.1.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-adservices"],"cli":null},"imports":["import AdServices","from AdServices import AAAttribution"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import AdServices\nimport objc\nfrom Foundation import NSLog\nfrom PyObjCTools import AppHelper\n\ndef attribution_completion_handler(token, error):\n    \"\"\"Callback function for the attribution token request.\"\"\"\n    if error:\n        NSLog(\"Error requesting AdServices attribution token: %@\", error)\n    else:\n        NSLog(\"AdServices Attribution Token: %@\", token)\n    AppHelper.stopEventLoop() # Stop the event loop after receiving the token\n\ndef request_token():\n    \"\"\"Initiates the request for an AdServices attribution token.\"\"\"\n    NSLog(\"Requesting AdServices attribution token...\")\n    # The Objective-C method 'requestAttributionTokenWithCompletionHandler:'\n    # translates to 'requestAttributionTokenWithCompletionHandler_' in PyObjC\n    # (note the trailing underscore for methods that take blocks/callbacks).\n    AdServices.AAAttribution.requestAttributionTokenWithCompletionHandler_(attribution_completion_handler)\n\nif __name__ == \"__main__\":\n    # Call the request function directly\n    request_token()\n    # For asynchronous operations (like network requests with callbacks),\n    # a run loop is often needed to process the callback.\n    # AppHelper.runEventLoop() keeps Python running until stopEventLoop() is called.\n    AppHelper.runEventLoop()","lang":"python","description":"This example demonstrates how to request an attribution token using Apple's AdServices framework via PyObjC. It defines a completion handler to process the token or any errors, and uses `PyObjCTools.AppHelper.runEventLoop()` to manage the asynchronous callback.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.7,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-adservices","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.7,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}