I am trying to make a macOS app using Xcode 12.4 , that opens webpages. When I try to use Web.load(URLRequest(url: URL(string: "https://google.com")!))
, I see an empty window.
I use a WKWebView in Main.storyboard
Here is the ViewController.swift code:
import Cocoa
import WebKit
let webView = WKWebView()
class ViewController: NSViewController {
@IBOutlet weak var Search: NSSearchField!
@IBOutlet weak var Web: WKWebView!
var web: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
Web.load(URLRequest(url: URL(string: "https://google.com")!))
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
I just found the simplest solution to this problem: remove the App Sandbox! More information about this here: https://developer.apple.com/forums/thread/92265