title: Load files from local file system into WKWebView website served from file:// URL
body: <p>Apologies in advance if I've left out any relevant information in this question: I am not a web developer, so I'm not sure exactly what information is necessary to solve my problem. </p>
  
  <p>I have a WKWebView that loads a website served locally, using code approximately like this (some details involving the manager are omitted, which I don't think are relevant to this question).</p>
  
  <pre><code>  WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init];
    WebViewManager *manager = [[WebViewManager alloc] init];
    webViewConfiguration.userContentController = manager;
    WKWebView *aWebView = [[WKWebView alloc] initWithFrame:self.view.bounds
                                             configuration:webViewConfiguration];
    [aWebView loadRequest:[NSURLRequest requestWithURL:aUrl]];
    [aWebView setNavigationDelegate:manager];
  </code></pre>
  
  <p>The HTML files for this website are stored in the App's bundle (a <code>file://</code> URL), and need to be able to access various images, CSS files, JS files, and other resources that are stored in the same directory in the bundle (there are relative URLS in the HTML for this purpose, I believe).</p>
  
  <p>I now need to be able to provide images from the App's shared container (as accessed by the <code>containerURLForSecurityApplicationGroupIdentifier:</code> method of <code>NSFileManager</code>). </p>
  
  <p>However, the URLs I provide don't work. When I view page in the Safari Debugger, I see an exception is being thrown in some jQuery Code that involves loading files.</p>
  
  <p>I've investigated a number of possible workarounds, but none of them have solved my issue:</p>
  
  <p>The new <code>loadFileURL:allowingReadAccessToURL:</code> method appeared to be just what I need, however, setting the <code>readAccessURL</code> parameter to the folder in my shared security container broke the website -- indeed, it didn't even look like the HTML files themselves loaded properly, as none of them had the right names in the Safari Debugger. As a test, I set the URL to the URL in the bundle of the directory containing the HTML pages, and got a <em>different</em> error. </p>
  
  <p>Another developer suggested that we convert each image from outside the bundle into a base64-encoded string and pass it into the website via Javascript, but that seems terribly inefficient to me, so I'm hoping to avoid that outcome. </p>
  
  <p>Finally, I've read elsewhere that copying files into the <code>tmp/www</code> directory of the app solves similar issues to this on iOS 8; so I wonder if copying everything into the same directory (outside of the bundle, which of course is read-only) might fix this. However, this too seems grossly inefficient. </p>
  
  <p>How can I load files both from inside the bundle and in the shared application container into my web view?</p>