From ec16fee79fa7bf3c172bd5bf095f8ca109189c62 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Mon, 11 Sep 2023 14:20:53 +0200 Subject: [PATCH] feat(ios): Make WebView inspectable (#1015) --- src/ios/CDVWKInAppBrowser.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 2adcf0c1b..5cf8e1570 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -18,6 +18,7 @@ Licensed to the Apache Software Foundation (ASF) under one */ #import "CDVWKInAppBrowser.h" +#import #if __has_include() // Cordova-iOS >=6 #import @@ -774,6 +775,21 @@ - (void)createViews self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration]; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400 + // With the introduction of iOS 16.4 the webview is no longer inspectable by default. + // We'll honor that change for release builds, but will still allow inspection on debug builds by default. + // We also introduce an override option, so consumers can influence this decision in their own build. + if (@available(iOS 16.4, *)) { +#ifdef DEBUG + BOOL allowWebviewInspectionDefault = YES; +#else + BOOL allowWebviewInspectionDefault = NO; +#endif + self.webView.inspectable = [_settings cordovaBoolSettingForKey:@"InspectableWebview" defaultValue:allowWebviewInspectionDefault]; + } +#endif + [self.view addSubview:self.webView]; [self.view sendSubviewToBack:self.webView];