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.

WKWebView could not access local javascript files
 
 
Q