I have a similar issue reading PDF file from Main Bundle. File exists there, but it cannot be presented to te user. I use QuickLook framework. And yes, all was working fine before iOS 11.2
Here is the part of code:
func previewController(_ controller: QLPreviewController, previewItemAt index:Int) -> QLPreviewItem {
let path = Bundle.main.url(forResource: episode, withExtension: "pdf")
let url = NSURL.fileURL(withPath: (path?.path)!)
return url as QLPreviewItem
}
override func viewDidLoad() {
...
let viewPDF = QLPreviewController()
present(viewPDF, animated:false, completion:nil)
}
The error I am getting after update on 11.2 is:
Couldn't issue file extension for url: file///var/containers/Bundle/Application/BD468...../NameOfApp.app/File001.pdf #PreviewItem
If I copy all the PDF files (around 200Mb) from Main Bundle to Documents Folder and change path, it works fine.
let path = FileManager.default.urls(for: .documentsDirectory, in: .userDomainMask).first?.appendingPathComponent(episode+".pdf")
But the problem is that now I have double size of PDFs (400 Mb), since I can't move or remove files from Main Bundle.
Any idea?