Bug (with fix): WebBrowserComponent / WKWebView can't open file:// urls from sandboxed apps

on macos/ios i wasn’t able to get WebBrowserComponent to load a local html file. after digging for a while i discovered WKWebView doesn’t handle file:// urls correctly when using loadRequest. instead you have to use loadFileURL with the allowingReadAccessToURL parameter.

also, even with this patch you still need to enable the Network: Outgoing Connections (Client) sandbox entitlement to access local files.

i submitted a pr for this but wanted to post here as well since there are a few related topics about not being able to load local html files in a WebBrowserComponent.

3 Likes