Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView doesn't present the HTML string in Mac OSX

In new xCode 9.0: I tried simply to load a HTML string inside webView (WKWebView) but I got a blank screen! The strange thing is the same code is works in my other computer!

Is this a bug?

Here is the code

    let filePath = Bundle.main.path(forResource: "my HTML file name", ofType: "html")
    let htmlStr = try! NSString.init(contentsOfFile: filePath!, encoding: String.Encoding.utf8.rawValue)
    webView.loadHTMLString(htmlStr as String, baseURL: nil)
like image 723
Nayef Avatar asked Jan 29 '23 09:01

Nayef


1 Answers

You have to allow 'Outgoing Connections (Client)' in the project's capabilities. Make sure these are added to the entitlements file as well.

I know, it does not make any sense if you don't make any outgoing connections and just pure HTML, but this made it work for me.

like image 67
CodeR70 Avatar answered Jan 31 '23 22:01

CodeR70