Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable webkit inspector for iOS and Cocoa. #2109

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/2109.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The WebKit inspector is automatically enabled on all webviews, provided you're using macOS 13.3 (Ventura) or iOS 16.4, or later.
8 changes: 8 additions & 0 deletions cocoa/src/toga_cocoa/widgets/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def create(self):
self.native.interface = self.interface
self.native.impl = self

# Enable the content inspector. This was added in macOS 13.3 (Ventura). It will
# be a no-op on newer versions of macOS; you need to package the app, then run:
#
# defaults write com.example.appname WebKitDeveloperExtras -bool true
#
# from the command line.
self.native.inspectable = True

self.native.navigationDelegate = self.native
self.native.uIDelegate = self.native

Expand Down
14 changes: 9 additions & 5 deletions docs/reference/api/widgets/webview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ Notes
* Using WebView on Linux requires that the user has installed the system packages
for WebKit2, plus the GObject Introspection bindings for WebKit2.

* On macOS, the "inspect element" feature is not enabled by default. WebView
debugging is only available when your code is packaged as a full macOS app
(e.g., with Briefcase). To enable debugging, run:
* On macOS 13.3 (Ventura) and later, the content inspector for your app can be opened by
running Safari, `enabling the developer tools
<https://support.apple.com/en-au/guide/safari/sfri20948/mac>`__, and selecting your
app's window from the "Develop" menu.

On macOS versions prior to Ventura, the content inspector is not enabled by default,
and is only available when your code is packaged as a full macOS app (e.g., with
Briefcase). To enable debugging, run:

.. code-block:: console

$ defaults write com.example.appname WebKitDeveloperExtras -bool true

Substituting ``com.example.appname`` with the bundle ID for your packaged
app.
Substituting ``com.example.appname`` with the bundle ID for your packaged app.

Reference
---------
Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ tvOS
Ubuntu
validator
validators
Ventura
verbing
viewport
watchOS
Expand Down
4 changes: 4 additions & 0 deletions iOS/src/toga_iOS/widgets/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def create(self):
self.native.interface = self.interface
self.native.impl = self

# Enable the content inspector. This was added in iOS 16.4.
# It is a no-op on earlier versions.
self.native.inspectable = True

self.native.navigationDelegate = self.native
self.native.uIDelegate = self.native

Expand Down