Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Developer Tools option setting for Blazor Hybrid Mac Catalyst view. #19909

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/BlazorWebView/src/Maui/iOS/BlazorWebViewHandler.iOS.cs
Expand Up @@ -80,9 +80,6 @@ protected override WKWebView CreatePlatformView()
Configuration = config
});

// Legacy Developer Extras setting.
config.Preferences.SetValueForKey(NSObject.FromObject(DeveloperTools.Enabled), new NSString("developerExtrasEnabled"));

config.UserContentController.AddScriptMessageHandler(new WebViewScriptMessageHandler(MessageReceived), "webwindowinterop");
config.UserContentController.AddUserScript(new WKUserScript(
new NSString(BlazorInitScript), WKUserScriptInjectionTime.AtDocumentEnd, true));
Expand All @@ -96,10 +93,16 @@ protected override WKWebView CreatePlatformView()
AutosizesSubviews = true
};

if (OperatingSystem.IsIOSVersionAtLeast(16, 4) || OperatingSystem.IsMacCatalystVersionAtLeast(13, 3))
if (DeveloperTools.Enabled)
{
// Enable Developer Extras for Catalyst/iOS builds for 16.4+
webview.SetValueForKey(NSObject.FromObject(DeveloperTools.Enabled), new NSString("inspectable"));
// Legacy Developer Extras setting.
config.Preferences.SetValueForKey(NSObject.FromObject(true), new NSString("developerExtrasEnabled"));

if (OperatingSystem.IsIOSVersionAtLeast(16, 4) || OperatingSystem.IsMacCatalystVersionAtLeast(16, 6))
{
// Enable Developer Extras for iOS builds for 16.4+ and Mac Catalyst builds for 16.6 (macOS 13.5)+
webview.SetValueForKey(NSObject.FromObject(true), new NSString("inspectable"));
}
}

VirtualView.BlazorWebViewInitialized(new BlazorWebViewInitializedEventArgs
Expand Down