For anyone that’s using (Desktop)HTMLViewer in their macOS projects that needs the ability to debug the underlying HTML code using the developer extras that are available in Safari, I’ve put together a pair of extension methods below.
Note: These use a Private API which is why they’re blocked behind a DebugBuild compiler directive! Use of this method will cause your app to be rejected in the App Store approval process!
Public Sub EnableDeveloperExtras(Extends ctl as HTMLViewer, assigns value as boolean)
#if TargetMacOS and DebugBuild
Declare Function getConfiguration Lib "WebKit" selector "configuration" (obj as integer) As Ptr
Declare Function getPreferences Lib "WebKit" selector "preferences" (obj as ptr) As Ptr
Declare sub _setDeveloperExtrasEnabled lib "WebKit" selector "_setDeveloperExtrasEnabled:" (obj as ptr, value as Boolean)
dim config as ptr = getConfiguration(ctl.Handle)
dim prefs as ptr = getPreferences(config)
_setDeveloperExtrasEnabled(prefs, value)
#endif
End Sub
Public Sub EnableDeveloperExtras(Extends ctl as DesktopHTMLViewer, assigns value as Boolean)
#if TargetMacOS and DebugBuild
Declare Function getConfiguration Lib "WebKit" selector "configuration" (obj as ptr) As Ptr
Declare Function getPreferences Lib "WebKit" selector "preferences" (obj as ptr) As Ptr
Declare sub _setDeveloperExtrasEnabled lib "WebKit" selector "_setDeveloperExtrasEnabled:" (obj as ptr, value as Boolean)
dim config as ptr = getConfiguration(ctl.Handle)
dim prefs as ptr = getPreferences(config)
_setDeveloperExtrasEnabled(prefs, value)
#endif
End Sub