I'm trying to load a pdf that is stored in my app, here is the code that I have
import UIKit
import PDFKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let pdfView = PDFView(frame: UIScreen.main.bounds)
let url = Bundle.main.url(forResource: "example", withExtension: "pdf")
pdfView.document = PDFDocument(url: url!)
self.view.addSubview(pdfView)
}
When I am running in simulator, I am getting the error that fatal error: unexpectedly found nil while unwrapping an Optional value in the debug are it is showing that url is nil .Any idea how to resolve it? I am running swift 4 and iOS 11 as target
