I have an html file located in a bundle and I'm using WKWebView to load content from this html:
let fileURL = URL(fileURLWithPath: Bundle.main.path(forResource:"demo", ofType: "html")!)
webView.loadFileURL(fileURL, allowingReadAccessTo: fileURL)
However, this html file have some scripts which are trying to get access to files located in Documents dir (some videos saved in there) but get a "can't load local resources." error. I'm using this files somewhere else in AVPlayerViewController so I know the files exists and the url I'm using is the right one.
I tried:
1. pass the documents dir url to the allowingReadAccessTo parameter - the webview doesn't even load
2. Copy the items from documents dir to tmp dir and passing this (tmp dir) url in the scripts - it works, but this process happens too much and I don't want to copy so many files due to memory issues and the time it take for big files.
3. Copy the html file and its scripts from the bundle to documents dir - not relevant because the scripts Im using changes from time to time, so to make sure the user always have the last version (of the scripts) I will have to copy it every time the app launches.
So, is there any other way to allow html file (located in bundle) access the documents file?
Thanks in advance,