Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView Could not create a sandbox extension for '/'

I would like to use external file .html to use WKWebView. Or is there a solution without external file ? All is working good on simulator, but not on device...

Here is my code :

NSString *path = [[NSBundle mainBundle] pathForResource:@"myHTML" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
WKWebViewConfiguration *theConfiguration =
[[WKWebViewConfiguration alloc] init];
[theConfiguration.userContentController
 addScriptMessageHandler:self name:@"interOp"];
_webView = [[WKWebView alloc] initWithFrame:self.view.frame
                                 configuration:theConfiguration];
[_webView loadRequest:request];
[self.view addSubview:_webView];

I've read this topic : WKWebView not loading local files under iOS 8

I don't want to use a server. I'm using Objective-C, and I want that it works on only one view, not like the https://github.com/shazron/WKWebViewFIleUrlTest project with 2 views and button and I need to have connexion with internet in the page (read iFrame).

What have I to do ?

like image 371
Vjardel Avatar asked Sep 15 '25 03:09

Vjardel


1 Answers

You have to copy all your web files to the app's NSTemporaryDirectory and call your index.html from there. Works fine on iOS 8.3 for me.

like image 63
iquellis Avatar answered Sep 16 '25 18:09

iquellis