WKWebView cannot load files using file:// URL protocol since iOS 8 beta 4 and 5

Number:rdar://18039024 Date Originated:08-15-2014
Status:Duplicate/17761459 Resolved:
Product:iOS SDK Product Version:iOS 8 beta 5
Classification:Serious Bug Reproducible:Always
WKWebView cannot load files using file:// URL protocol that is within the app sandbox since iOS 8 beta 4 and 5. This worked in beta 3, and still works in the iOS 8 beta simulators (all beta versions).

Steps to Reproduce:
1. Create a file in your Documents folder (or Library, or Library/Caches, or tmp, or even load something in your app bundle)
2. Load that file in WKWebView as a file:// URL
3. The file will not load and result in an error 

Expected Results:
WKWebView can load a file from a file URL from the app's sandbox (Documents, Library, Library/Caches, tmp, app bundle)

Actual Results:
WKWebView will not load a file from a file URL from the app's sandbox (Documents, Library, Library/Caches, tmp, app bundle)

iOS 8 beta 5

I included a sample project demonstrating the issue. The sample project is also here: https://github.com/shazron/WKWebViewFIleUrlTest

iPhone 5

Duplicate of 17761459 (Open) - as of Aug 21st 2014


partially fixed in iOS9 béta5

In iOS9 béta5 we're able to load a simple html5 file shipped with the APP.

But still resulting in XHR errors for loading files from the local file system.

Seems that WKWebView blocks local XHR request file://..... Error: Cross origin requests are only supported for HTTP.

By axel.segers at Sept. 3, 2015, 2:12 p.m. (reply...)

Still an issue in 8.2

Duped http://openradar.appspot.com/20160687

Marked as a dup of 17761459

By benchatelain at March 13, 2015, 11:23 p.m. (reply...)

Is there any update on this problem, as it seems like it's a bit of a showstopper for applications that are run from the bundle files and do any sort of file:// operations.

By Stephen.Andrew.Varley at Nov. 26, 2014, 10:24 a.m. (reply...)

This is also affecting camera access via file:// in the facebook app webview. Currently it crashes the webview and won't allow others to be launched.

By adamwpalmer at Oct. 24, 2014, 9:39 a.m. (reply...)

Already fixed in WebKit: https://devforums.apple.com/message/1051027

Not sure when it will land in iOS 8 patch release.

loadRequest throws an exception if loaded using a file URL based on this http://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.h#L54

The bug is still there with iOS 8 GM firmware

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!