I have an App which moves all HTML files to my own folder on the iPhone:
file:///var/mobile/Containers/Data/Application/AD332281-2ADE-4809-ABF2-F3FC3004AF42/Documents/MOTHER-APP/index.html
and:
file:///var/mobile/Containers/Data/Application/AD332281-2ADE-4809-ABF2-F3FC3004AF42/Documents/MOTHER-APP/css/mother.css
The problem is - when the App loads the index.html file into webview no CSS files are available.
I have tested if the index file and the CSS file exists and it is all there.
I have tried both:
webView.loadHTMLString(indexfile, baseURL: baseUrl)
and:
webView.loadFileURL(destinationURLForFile, allowingReadAccessTo: destinationURLForFile)
The HTML index file requests the CSS like this:
< link rel="stylesheet" type="text/css" href="css/mother.css" />
Ok, I retried with Documents dir urls, and this worked:
let documentDirUrl = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
let indexFileUrl = documentDirUrl.appendingPathComponent("index.html")
webView.loadFileURL(indexFileUrl, allowingReadAccessTo: documentDirUrl)
Documents directory on simulator is diffrent from the real device, it's as usual.
How have you made those urls?
(Note: I have no entry for App Transport Security in the plist of my test project.)