How to disable web security in iOS WKWebView? I used command "open /Applications/Google\ Chrome.app --args --disable-web-security --allow-file-access-from-files" in mac system to open the chrome. But How to do this in WKWebView? Thankes!
It's not possible to disable web security in WKWebView - there's no preference to do so - see the iOS source code for WebKit preferences.
There is a way to allow access from file URLs, although it's not officially supported. In the source code, a preference exists, so you can set it like this:
[wkWebView.configuration.preferences setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
This enables access to file URLs relative to the content src. e.g. if the local page is foo/bar/index.html
you can access files in foo/bar/
(e.g. foo/bar/1.jpg
or foo/bar/sub/2.jpg
) but not outside (e.g. foo/other/3.jpg
or Documents/NoCloud/4.jpg
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With