I have a WKWebView
that works perfectly fine when given a URL
or a URLRequest
, but when I am trying to load local bundle html files into it, it just doesn't display anything.
I am trying it like so:
let webView = WKWebView()
if let bundleURL = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "mySubDirectory/v1") {
webView.loadFileURL(bundleURL, allowingReadAccessTo: bundleURL.deletingLastPathComponent())
}
I have tested that the bundleURL
actually returns the right path and tried copying + pasting it in my browser at run time and it works great:
file:///Users/myuser/Library/Developer/Xcode/DerivedData/FireApp-gugmufgdkejtfdhglixebzhokhfe/Build/Products/Debug-iphonesimulator/SteppingIntoFireFramwork.framework/mySubDirectory/v1/index.html
What could be the problem?