Skip to content

Support BrowserComponent.setDebugMode on iOS #3868

@Rocketeer007

Description

@Rocketeer007

Is your feature request related to a problem? Please describe.
When working with a BrowserComponent, it is a lot easier to understand what's going on if you are able to use Safari to debug JavaScript inside the WKWebView. Currently, this is not supported without manually editing generated iOS native code.

Describe the solution you'd like
Calling BrowserComponent.setDebugMode(true) should, ideally, result in a call to wkWebView.inspectable = YES;, and disabling this should set it back to NO.

Describe alternatives you've considered
Manually editing the iOS native code works:

Subject: [PATCH] Make WKWebView inspectable
---
Index: Ports/iOSPort/nativeSources/IOSNative.m
<+>UTF-8
===================================================================
diff --git a/Ports/iOSPort/nativeSources/IOSNative.m b/Ports/iOSPort/nativeSources/IOSNative.m
--- a/Ports/iOSPort/nativeSources/IOSNative.m	(revision 329216c760660a63198c26b0e87224476cfa2760)
+++ b/Ports/iOSPort/nativeSources/IOSNative.m	(date 1738323512897)
@@ -2489,6 +2489,7 @@
             com_codename1_impl_ios_IOSNative_createWKBrowserComponent.backgroundColor = [UIColor clearColor];
             com_codename1_impl_ios_IOSNative_createWKBrowserComponent.opaque = NO;
             com_codename1_impl_ios_IOSNative_createWKBrowserComponent.autoresizesSubviews = YES;
+            com_codename1_impl_ios_IOSNative_createWKBrowserComponent.inspectable = YES;
             
             com_codename1_impl_ios_IOSNative_createWKBrowserComponent.navigationDelegate = del;
             com_codename1_impl_ios_IOSNative_createWKBrowserComponent.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);

We could also consider adding a build hint that would turn this on or off for an entire project.

Additional context
Reddit discussion: https://www.reddit.com/r/cn1/comments/1idt7ez/webbrowser_javascript_interoperability_debugging/

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions