I am rendering a local index.html file inside my Xcode project, using WKWebView. The thing is, the html and css code inside the file are successfully displayed inside the webView, but the javaScript however, is not rendered at all.
I have searched similar questions on this issue on stackoverflow and what I came up with is that Apple does not execute js in a local html file, and in order to execute js I am required to use a local webserver using GCDWebServer.
To be honest I am new to the hole webServer concept and I'm finding it hard to figure how to run the html in a local webServer and how to this with GCDWebServer.
What's the simple way to run my index.html file on a local server inside WKWebView and how to do so
here is my code:
override func viewDidLoad() {
super.viewDidLoad()
let resourceUrl = Bundle.main.url(forResource: "index", withExtension: "html")
let urlRequest = URLRequest.init(url: resourceUrl!)
webView.load(urlRequest)
webView.allowsBackForwardNavigationGestures = true
}
<script src="file.js"></script>? - Hudi Ilfeld