Unlike with UIWebView and previous versions of WKWebView (iOS 10 & macOS 10.12), the default load operation for local files has moved from Bundle.main.path
to Bundle.main.url
. Similarly, loadFileURL
has also become the default function to load local resources in WKWebView.
I know that .path
and .url
are entirely different and have both worked in the past – .path
historically being the default-chosen method; however, it seems that the latest versions of Swift have broken most, if not all, .path
solutions. The .path
solutions seem to now flatten the directory hierarchy, putting all of the CSS, JS, and any other sub-directory contents, into one big directory. This causes loading errors when WKWebView attempts to load index.html, for example, with a linked, sub-folder stylesheet (ie. /css/style.css
).
After seeing numerous questions and countless uncertain/broken answers to match, is there a quick and painless solution for implementing a WKWebView that can load local resources (including linked CSS/JS files), without any workarounds?