Loading PDF in WKWebView from Bundle for MacOS App through Catalyst Tool Xcode 11

Viewed 737

I am using WKWebView to Load PDF file from the bundle, and it works fine in iPad Device and simulator both, but when I debug that same code for Mac OS app with the help of Mac Catalyst, it just shows Blank white screen In Mac App Simulator, nothing happens.

Here is my code to load pdf from Bundle : -

import UIKit
import WebKit

class ViewController: UIViewController,WKNavigationDelegate{

    @IBOutlet weak var webKit: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        if let pdf = Bundle.main.url(forResource: "sample", withExtension: "pdf", subdirectory: nil, localization: nil)  {
           let req = NSURLRequest(url: pdf)
            webKit.load(req as URLRequest)
         }
    }

and it throws this error in console :-

Could not create a 'com.apple.iphone.axserver-systemwide' sandbox extension

Even though I have configured app sandbox :-

Have a look here

I am using - Xcode 11.1 - macOS 10.15

1 Answers

WKWebView will not (currently) display PDF's using Catalyst on macOS. Use PDFView.

Related