feat(ios): Make WebView inspectable (#1015)

This commit is contained in:
jcesarmobile 2023-09-11 14:20:53 +02:00 committed by GitHub
parent 178f2d3e59
commit ec16fee79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@
*/
#import "CDVWKInAppBrowser.h"
#import <Cordova/NSDictionary+CordovaPreferences.h>
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>) // Cordova-iOS >=6
#import <Cordova/CDVWebViewProcessPoolFactory.h>
@ -774,6 +775,21 @@ BOOL isExiting = FALSE;
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];