how do I get WKWebView to work in swift and for an macOS App

Solutions Collect From Internet About “how do I get WKWebView to work in swift and for an macOS App”

I recommend you to start from the scratch:

Set Your URL to be loaded:

let myURLString = "https:yourWebLink"
let url = NSURL(string: myURLString)
let request = NSURLRequest(URL: url!)  

Init and load request in webview:

    webView = WKWebView(frame: self.view.frame)
    webView.navigationDelegate = self
    webView.loadRequest(request)

Implement WKNavigationDelegate to trace your page Load/Error:

func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) {
    print(error.localizedDescription)
}
func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
    print("Strat to load")
}
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
    print("finish to load")
}

Dont forget to add delegate WKNavigationDelegate in ViewController.swift file.

class ViewController: UIViewController , WKNavigationDelegate{

For further reference check: https://iosdevcenters.blogspot.com/2016/05/creating-simple-browser-with-wkwebview.html