0

I open a default cocoa app; one for Mac OS and one for iOS using Storyboards. I drag a Web View (WKWebView) into the default view supplied by Storyboard. I modify the default ViewController.swift file so that for ios it reads

import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {

@IBOutlet weak var webView: WKWebView!

override func viewDidLoad() {
        super.viewDidLoad()
        webView.navigationDelegate = self
        let url=URL(string: "https://www.example.com")
        webView.load(URLRequest(url: url!))

        // Do any additional setup after loading the view.
    }

}

And for Mac OS it reads as follows

import Cocoa
import WebKit

class ViewController: NSViewController, WKNavigationDelegate {

@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
    super.viewDidLoad()
    webView.navigationDelegate = self
    let url=URL(string: "https://www.example.com")
    webView.load(URLRequest(url: url!))

    // Do any additional setup after loading the view.
}

override var representedObject: Any? {
    didSet {
        // Update the view, if already loaded.
       }
    }
}

I connect the webView variable to the Web View object the same in both projects. The iOS project does what I expect. The Mac OS project fails to display the example page although it appears to run; I just have a blank window. The question is

What am I doing wrong in Mac OS?

Also in Mac OS I get a message "Unable to load Info.plist exceptions (eGPUOverrides)".

I get that message for all my projects in the newer Xcode and have been unable to find any clues as to what it means. Just downloaded an updated Xcode today but I still get that message and still have this problem. Not sure if that relates or not to my question.

JVSIP
  • 381
  • 1
  • 9
  • 1
    Check Capabilities. – El Tomato Nov 01 '18 at 01:19
  • 1
    So after searching around for a check box called Capabilities I selected the project in the project navigator and found a Capabilities section. After turning off "App Sandbox" things worked fine. Also you can leave on "App Sandbox" and check the option for "outgoing connections (client)" and that will fix the problem. For more information search for Capabilities in the Help menu and find out about these selections. – JVSIP Nov 01 '18 at 01:58
  • i face this issue in xcode 11 beta 5.. can you please explain more with image by posting proper answer. – Hardik Thakkar Aug 08 '19 at 09:49
  • WKWebView working fine after updating mac OS to beta 5 – Hardik Thakkar Aug 08 '19 at 11:22

1 Answers1

0

Try enable App Sandbox in Capabilities settings. (I use Xcode 11.2, Swift 5 and it works fine)

enter image description here

Chhaileng
  • 2,428
  • 1
  • 27
  • 24