Registry / web-framework / pyobjc-framework-webkit

pyobjc-framework-webkit

JSON →
library12.2.2pypypiunverified

PyObjC-framework-WebKit provides Python wrappers for Apple's WebKit and JavaScriptCore frameworks on macOS, enabling Python applications to embed web content and execute JavaScript. It is part of the larger PyObjC project, which acts as a bridge between Python and Objective-C. The library is actively maintained with regular updates to support new macOS SDKs and Python versions, typically following a release cadence aligned with major macOS and Python releases.

pip install pyobjc-framework-webkit
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-W
P
pyobjc-framework-webkit
web-frameworkpythonv12.2.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.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

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

WebKit
import WebKit
The WebKit framework bindings are accessed directly through the 'WebKit' package.
AppKit
import AppKit
Most practical uses of WebKit will require AppKit for windowing and application management.
Foundation
import Foundation
Foundation framework provides core data types and utilities, often used with WebKit for URLs and requests.

This minimal example demonstrates how to create a basic macOS application window using AppKit and embed a WKWebView to display a webpage. It defines an AppDelegate to manage the application lifecycle and sets up a window with a WKWebView loading a URL. To run this, save it as a .py file and execute it on macOS with PyObjC installed. Note that a full macOS application with an Info.plist and bundle identifier is typically created using tools like `py2app` for deployment, but this script provides a runnable demonstration within a standard Python environment. The URL is conditionally set to avoid issues when run from an unbundled script without a default bundle ID.

import AppKit import Foundation import WebKit class AppDelegate(AppKit.NSObject): def applicationDidFinishLaunching_(self, notification): rect = Foundation.NSMakeRect(0, 0, 800, 600) self.window = AppKit.NSWindow.alloc().initWithContentRect_styleMask_backing_defer_( rect, AppKit.NSWindowStyleMaskTitled | AppKit.NSWindowStyleMaskClosable | AppKit.NSWindowStyleMaskResizable, AppKit.NSBackingStoreBuffered, False ) self.window.setTitle_("PyObjC WebKit Demo") self.webView = WebKit.WKWebView.alloc().initWithFrame_(rect) self.window.contentView().addSubview_(self.webView) url = Foundation.NSURL.URLWithString_("https://www.apple.com/" if not Foundation.NSBundle.mainBundle().bundleIdentifier() else "https://www.google.com") request = Foundation.NSURLRequest.requestWithURL_(url) self.webView.loadRequest_(request) self.window.makeKeyAndOrderFront_(None) def applicationShouldTerminateAfterLastWindowClosed_(self, sender): return True if __name__ == "__main__": app = AppKit.NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() app.setDelegate_(delegate) app.run()
Debug
Known issues
breakingPyObjC v12.0 dropped support for Python 3.9, and v11.0 dropped support for Python 3.8. Ensure your Python environment is 3.10 or newer for PyObjC 12.x.
fix
Upgrade to Python 3.10 or a newer supported version.
affects: 11.0+
breakingPyObjC v10.3 introduced a change where `__init__` methods in Python subclasses of Objective-C classes would not be called if a user-defined `__new__` was not present. This broke several projects. While partially reverted in v10.3.1 to allow `__init__` when a user *does* implement `__new__`, code relying on PyObjC's auto-generated `__new__` still cannot use `__init__` in the traditional Python sense.
fix
Upgrade to PyObjC 10.3.1 or newer. If implementing Objective-C style initializers, follow the `alloc().init...()` pattern or implement a custom `__new__` method in your Python class to allow `__init__` to be called.
affects: 10.3 - 10.3.0
gotchaBuilding PyObjC (including framework bindings) from source requires Xcode Command Line Tools to be installed, which provides the necessary compilers and SDKs. Without them, installation via `pip install --no-binary :all: pyobjc-framework-webkit` will fail.
fix
Install Xcode Command Line Tools using `xcode-select --install` in your terminal.
affects: All versions (when installing from source)
gotchaConflicting `AppKit` packages can cause `ImportError`. If you encounter 'No module named AppKit' after installing PyObjC, check if another non-PyObjC `AppKit` package is installed.
fix
Uninstall any conflicting `AppKit` packages (e.g., `conda uninstall AppKit` or `pip uninstall AppKit`) and then reinstall PyObjC packages (`pip install --upgrade --force-reinstall pyobjc pyobjc-core`).
affects: All versions
gotchaDue to the underlying Objective-C runtime, it's generally recommended to avoid subclassing `NSString` or `NSMutableString` in Python, as these classes have special handling in PyObjC and direct subclassing can lead to crashes.
fix
If you need string-like behavior, wrap `NSString` instances or use Python's built-in string types instead of subclassing directly.
affects: All versions
Upgrade
Version history
12.2.2latest on PyPI · released Aug 11, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides the core bridge between Python and Objective-C, essential for all PyObjC framework bindings. It is implicitly installed as a dependency.
pyobjc-framework-CocoaoptionalWhile not a direct PyPI dependency, WebKit applications typically rely on AppKit (part of Cocoa) for UI elements like windows and application loops.
Agent activity
5 hits · last 30 days
node
4
Resources
pyobjc-framework-webkit — pip install pyobjc-framework-webkit · libregistry