{"id":6075,"library":"pyobjc-framework-browserenginekit","title":"PyObjC BrowserEngineKit Bindings","description":"PyObjC provides Python bindings for the BrowserEngineKit framework on macOS, allowing Python applications to embed web content rendering capabilities. It is part of the larger PyObjC project, which wraps many macOS frameworks. Version 12.1 is current, with releases typically aligning with macOS SDK updates and Python version support changes.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objective-c","cocoa","ui","web","browser","webkit"],"install":[{"cmd":"pip install pyobjc-framework-browserenginekit","lang":"bash","label":"Install specific framework"},{"cmd":"pip install pyobjc","lang":"bash","label":"Install all PyObjC frameworks"}],"dependencies":[{"reason":"Core bridge between Python and Objective-C, required for all PyObjC framework bindings.","package":"pyobjc-core"}],"imports":[{"note":"Classes from BrowserEngineKit are typically imported directly from the 'BrowserEngineKit' package.","symbol":"BEBrowserViewController","correct":"from BrowserEngineKit import BEBrowserViewController"}],"quickstart":{"code":"import objc\nfrom AppKit import NSApplication, NSWindow, NSMakeRect\nfrom BrowserEngineKit import BEBrowserViewController\nfrom PyObjCTools import AppHelper # Common for PyObjC GUI apps\n\nclass MyBrowserViewController(BEBrowserViewController):\n    # A minimal subclass just to demonstrate extending BEBrowserViewController\n    pass\n\nclass AppDelegate(objc.NSObject):\n    def applicationDidFinishLaunching_(self, notification):\n        self.mainWindow = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(\n            NSMakeRect(100, 100, 800, 600),\n            4 | 8 | 1 | 2, # Titled, Closable, Miniaturizable, Resizable\n            2, # NSBackingStoreBuffered\n            False\n        )\n        self.mainWindow.setTitle_(\"PyObjC BrowserEngineKit Demo\")\n\n        self.browserVC = MyBrowserViewController.alloc().init()\n        self.mainWindow.setContentView_(self.browserVC.view())\n        self.mainWindow.makeKeyAndOrderFront_(None)\n\ndef main():\n    app = NSApplication.sharedApplication()\n    delegate = AppDelegate.alloc().init()\n    app.setDelegate_(delegate)\n    AppHelper.runEventLoop() # Starts the macOS event loop\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"This example demonstrates how to instantiate a `BEBrowserViewController` within a minimal macOS GUI application using PyObjC. It creates a simple window and embeds the browser view controller's view into it. Running this code requires a macOS environment and will display an empty browser window."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or newer (for PyObjC 12.x) and regularly update Python alongside PyObjC.","message":"Python 3.9 support was dropped in PyObjC 12.0. Python 3.8 support was dropped in PyObjC 11.0. Future versions will continue to drop support for older Python versions as they reach end-of-life.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Review object lifecycle management, especially around custom Objective-C `init` methods defined in Python, to ensure correct reference counting behavior.","message":"PyObjC 11.1 introduced changes to how Objective-C Automatic Reference Counting (ARC) rules are modeled for 'init' family methods, aligning with `clang`'s documentation. This means `init` methods now correctly 'steal' a reference to `self` and return a new one, potentially affecting custom memory management or object lifecycle expectations.","severity":"breaking","affected_versions":"11.1+"},{"fix":"If implementing `__new__`, carefully manage initialization logic. For classes relying on PyObjC's `__new__`, avoid implementing `__init__`.","message":"PyObjC 10.3 changed the interaction between Python's `__init__` and `__new__` methods. While 10.3.1 partially reverted this for user-implemented `__new__` methods, code relying on `__new__` provided by PyObjC cannot use `__init__`.","severity":"breaking","affected_versions":"10.3+"},{"fix":"Avoid using PyObjC in free-threaded Python 3.13 environments, or ensure Python is run in a mode that disables free-threading if using PyObjC.","message":"PyObjC does not support Python's experimental free-threading (PEP 703) in Python 3.13, despite binary wheels being available. Running PyObjC in a free-threaded Python environment may lead to instability.","severity":"gotcha","affected_versions":"10.3+ with Python 3.13"},{"fix":"Refactor code using `objc.classAddMethods` to ensure only `MethodType` or `FunctionType` objects are passed as method implementations.","message":"`objc.classAddMethods` no longer supports passing arbitrary callable types (e.g., `functools.partial`) as method implementations. Only `MethodType` or `FunctionType` values are accepted.","severity":"breaking","affected_versions":"12.1+"},{"fix":"Check the release notes for major PyObjC versions if you receive import errors for frameworks. Migrate away from any frameworks deprecated and removed by Apple/PyObjC.","message":"Entire frameworks that were deprecated by Apple have been removed from PyObjC bindings. For example, `IMServicePlugIn` was removed in PyObjC 10.0.","severity":"breaking","affected_versions":"10.0+"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}