I am trying to load an HTML file from Bundle
. This is the code I use,
let fileUrl = Bundle.main.url(forResource: "index", withExtension: "html")!
webView.loadFileURL(fileUrl, allowingReadAccessTo: fileUrl)
If it is a simple HTML file, I see WKWebview
is loading them fine. But right now I am trying to load the HTML which is created using React Native. I don't see any problem with React native web code because its loading fine in local.
While checking logs, I just found that it is failing to load *.js file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover"
/>
<title>Bundle HTML</title>
</head>
<div id="root"></div>
<script src="/bundles/web-4587a25eab359d254810d3f9017eb281.js"></script>
</html>
Not sure why the this js & other resources not loading fine. Any idea?
I have added the following config for WKWebView
as well.
allowsContentJavaScript
as true and allowFileAccessFromFileURLs
as true