WKWebView could not access local javascript files

We are experiencing an issue after Xcode 26.0 to load local javascript files to WKWebView to render our own design.

it used to work well, however after Xcode 26.0, when

[self.webView loadFileURL:fileURL allowingReadAccessToURL:accessURL];

it returns [PID=1514] WebProcessProxy::hasAssumedReadAccessToURL(3198190): no access

self.webRootPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:CHAT_VIEW_WEB_ROOT];

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;

if (! [fileManager fileExistsAtPath:self.webRootPath]){
	[fileManager createDirectoryAtPath:self.webRootPath withIntermediateDirectories:NO attributes:nil error:&error];
}
NSURL *accessURL = [NSURL fileURLWithPath:self.webRootPath];

Not sure how to assign access permission to WKWebView.

Any help much appreciated.

Answered by pvollan in 880719022

Hi,

If this is still reproducing, could you file a feedback report, and possibly attach a demo Xcode project that is reproducing the issue?

here is error signature:

start setting access permission file:///var/mobile/Containers/Data/Application/9044BAAF-5152-4C71-A3BA-5292C6FEED70/Documents/cv_webroot/CM_chat_view_base.html with accessURL file:///var/mobile/Containers/Data/Application/9044BAAF-5152-4C71-A3BA-5292C6FEED70/Documents/cv_webroot/ 0x12c0d40c0 - [PID=1514] WebProcessProxy::hasAssumedReadAccessToURL(3198190): no access complete setting access permission file:///var/mobile/Containers/Data/Application/9044BAAF-5152-4C71-A3BA-5292C6FEED70/Documents/cv_webroot/CM_chat_view_base.html with accessURL file:///var/mobile/Containers/Data/Application/9044BAAF-5152-4C71-A3BA-5292C6FEED70/Documents/cv_webroot/

Hi,

Could you try resolving symlinks in accessURL? This can be done with the realpath function.

Accepted Answer

Hi,

If this is still reproducing, could you file a feedback report, and possibly attach a demo Xcode project that is reproducing the issue?

Thanks Apple, I filed DTS ticket, and get the solution from Apple Engineer. It is resolved.

On my end, it was due to call

[self.webView loadFileURL:fileURL allowingReadAccessToURL:accessURL]; multiple times, even though it was worked on earlier version.

here is the response from Apple side

The loadFileURL:allowingReadAccessToURL: call should be made only once, after all the resource files have been copied. The CSS and image files don't need to be loaded individually — they will be loaded automatically by the HTML when it references them, because your accessURL grants WKWebView read access to the entire cv_webroot directory. Here is what the corrected flow should look like:

hope this helps.

WKWebView could not access local javascript files
 
 
Q