I am stuck and don't know what to do. I want to be able to display PDF's within my application using QuickLook. I have imported my PDF files into my project and am using the code below to display it.
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
//let bundle = Bundle.main
let resourcePath = Bundle.main.resourceURL!.appendingPathComponent("Manuals/\(nodeName).pdf").path
//let path = resourcePath + bundle.path(forResource: nodeName, ofType: "pdf")!
let url = URL(fileURLWithPath: resourcePath)
return url as QLPreviewItem
}
The URL which is generated is
"file:///var/containers/Bundle/Application/3923DC1F-386E-4038-A8B1-A855483F4C06/Application%20v1.app/Manuals/CYB.pdf"
The error I'm getting is
Couldn't issue file extension for url: file:///var/containers/Bundle/Application/3923DC1F-386E-4038-A8B1-A855483F4C06/Application%20v1.app/Manuals/CYB.pdf #PreviewItem
and on the display Im just getting a grey screen with the name of the file and PDF Document under it. Does anybody know what Im doing wrong. I have tired to google the answer but either the solution did not work for me or the answer is outdated.
Any help would be great. If there is anymore information you might need let me know and I can provide that.
Thanks