Skip to content

Commit ec16fee

Browse files
authored
feat(ios): Make WebView inspectable (apache#1015)
1 parent 178f2d3 commit ec16fee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ios/CDVWKInAppBrowser.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Licensed to the Apache Software Foundation (ASF) under one
1818
*/
1919

2020
#import "CDVWKInAppBrowser.h"
21+
#import <Cordova/NSDictionary+CordovaPreferences.h>
2122

2223
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>) // Cordova-iOS >=6
2324
#import <Cordova/CDVWebViewProcessPoolFactory.h>
@@ -774,6 +775,21 @@ - (void)createViews
774775

775776

776777
self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration];
778+
779+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400
780+
// With the introduction of iOS 16.4 the webview is no longer inspectable by default.
781+
// We'll honor that change for release builds, but will still allow inspection on debug builds by default.
782+
// We also introduce an override option, so consumers can influence this decision in their own build.
783+
if (@available(iOS 16.4, *)) {
784+
#ifdef DEBUG
785+
BOOL allowWebviewInspectionDefault = YES;
786+
#else
787+
BOOL allowWebviewInspectionDefault = NO;
788+
#endif
789+
self.webView.inspectable = [_settings cordovaBoolSettingForKey:@"InspectableWebview" defaultValue:allowWebviewInspectionDefault];
790+
}
791+
#endif
792+
777793

778794
[self.view addSubview:self.webView];
779795
[self.view sendSubviewToBack:self.webView];

0 commit comments

Comments
 (0)