I've made a fresh mac app project with the following code in the ViewController.
import Cocoa
import WebKit
class ViewController: NSViewController {
var loginWebView: WKWebView!
override func viewDidLoad()
{
super.viewDidLoad()
self.loginWebView = WKWebView(frame: self.view.frame)
self.view.addSubview(loginWebView)
let urlReq = URLRequest(url: URL(string: "https://apple.com/")!)
self.loginWebView.load(urlReq)
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
For some reason when I launch the app the web view isn't loading the website. Why is this? I've been developing on iOS for years and am just getting started with macOS.
EDIT: Update loading a local file wouldn't work either
self.loginWebView.loadFileURL(fileURL, allowingReadAccessTo: dirURL)