{"id":6066,"library":"pyobjc-framework-adsupport","title":"PyObjC AdSupport Framework","description":"PyObjC-framework-adsupport provides Python bindings for Apple's AdSupport framework on macOS. It allows Python applications to interact with native macOS APIs to obtain the advertising identifier (IDFA), which is unique to each device and primarily used for advertising purposes. The library is part of the larger PyObjC project, which regularly releases updates, with major versions typically aligning with macOS SDK changes and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","cocoa","framework","adsupport","apple"],"install":[{"cmd":"pip install pyobjc-framework-adsupport","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This package provides the core bridge between Python and Objective-C, which is essential for all PyObjC framework wrappers to function.","package":"pyobjc-core"}],"imports":[{"note":"This is the top-level package for the AdSupport framework bindings.","symbol":"AdSupport","correct":"import AdSupport"}],"quickstart":{"code":"import AdSupport\nfrom Foundation import NSUUID\n\n# Note: On iOS 14.5+ and iPadOS 14.5+, your app must request\n# tracking authorization using the AppTrackingTransparency framework\n# (e.g., AppTrackingTransparency.ATTrackingManager.requestTrackingAuthorization_)\n# before a non-zero advertisingIdentifier can be obtained.\n# For macOS, AdSupport is available from 10.14+.\n\nmanager = AdSupport.ASIdentifierManager.sharedManager()\n\nif manager.isAdvertisingTrackingEnabled():\n    advertising_id_nsuuid = manager.advertisingIdentifier()\n    # Convert NSUUID to a Python string\n    advertising_id_str = str(advertising_id_nsuuid.UUIDString())\n    print(f\"Advertising ID (IDFA): {advertising_id_str}\")\nelse:\n    print(\"Advertising tracking is disabled. Advertising ID will be all zeros.\")\n    # The ID will be '00000000-0000-0000-0000-000000000000'\n    advertising_id_nsuuid = manager.advertisingIdentifier()\n    advertising_id_str = str(advertising_id_nsuuid.UUIDString())\n    print(f\"Advertising ID (IDFA): {advertising_id_str}\")","lang":"python","description":"This quickstart demonstrates how to access the shared instance of `ASIdentifierManager` and retrieve the `advertisingIdentifier`. It also includes a note about `App Tracking Transparency` requirements for obtaining a meaningful IDFA on modern iOS/iPadOS versions."},"warnings":[{"fix":"Upgrade to a supported Python version (3.10+ for PyObjC 12.1).","message":"PyObjC has consistently dropped support for older Python versions with major releases. PyObjC 12.0 dropped Python 3.9, and PyObjC 11.0 dropped Python 3.8. Users should verify their Python version compatibility when upgrading PyObjC.","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Review and update code to follow the new reference counting model. For object instantiation, prefer `SomeClass.alloc().init...()` or the more Pythonic `SomeClass(...)` syntax introduced in PyObjC 10.3.","message":"Version 11.1 aligned PyObjC's behavior with `clang`'s Automatic Reference Counting (ARC) documentation for initializer methods. This change can affect how references are managed, potentially leading to crashes if code relies on previous reference counting behavior, especially around `alloc()` and `init` methods. The `isAlloc` attribute of `objc.selector` is deprecated and will be removed in PyObjC 12.","severity":"breaking","affected_versions":">=11.1"},{"fix":"Only import and use the AdSupport framework if your application genuinely requires the IDFA for advertising. Ensure you implement App Tracking Transparency (AppTrackingTransparency.ATTrackingManager.requestTrackingAuthorization_) for iOS/iPadOS 14.5+ if using IDFA. Consider dynamically loading the framework if only conditional checks are needed and to avoid implicit linking.","message":"Merely referencing the `ASIdentifierManager` class (e.g., to check if the framework is linked) can cause the AdSupport framework to be linked by your application. This can lead to app rejections from Apple if your app doesn't actually use IDFA for advertising AND doesn't implement App Tracking Transparency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For Python classes subclassing Objective-C classes, ensure `__new__` and `__init__` interactions are well-defined. The recommended Pythonic way to instantiate Objective-C objects via PyObjC is `SomeClass(...)` or `SomeClass.alloc().init...()`.","message":"Initial PyObjC 10.3 versions broke `__init__` usage when combined with PyObjC-provided `__new__` for Objective-C subclasses. While 10.3.1 partially reverted this for user-implemented `__new__`, directly calling `__init__` on `alloc()`'d objects without a user-defined `__new__` might still be problematic.","severity":"gotcha","affected_versions":"10.3.x"},{"fix":"Ensure Xcode Command Line Tools are installed by running `xcode-select --install` in the terminal.","message":"Installation of PyObjC, including framework wrappers, often relies on Xcode Command Line Tools being installed on macOS. Missing tools can lead to compilation errors during `pip install`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult PyObjC release notes and Apple's documentation for framework compatibility with your target macOS version. Update code to use current APIs if deprecated ones are removed.","message":"Frameworks and specific symbols can be deprecated or entirely removed as Apple updates macOS SDKs. For example, the `IMServicePlugIn` framework bindings were removed in PyObjC 10.0 because the underlying framework was removed in macOS 14.","severity":"breaking","affected_versions":"Varies by framework/symbol (e.g., 10.0 for IMServicePlugIn)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}