1
votes

I am working on the new version of swift 4 and i have the next issue, i can not show a ".pdf" on a UIWebView. First i migrated my project to the new version of Swift, then i had to solve the issue of "Set Swift 3 @objc inference to Default", then when i run my project just some of the PDFs i set when i was working on Swift 3 are showing, i added new ones after upgrade the swift but does not show it on the UIWebView. This is my code to show the pdf files:

    func showCarPdf() {

    print(carPdfView!)

    if let pdf = Bundle.main.url(forResource: carPdfView!, withExtension: "pdf", subdirectory: nil, localization: nil)  {
        let req = NSURLRequest(url: pdf)
        webView.loadRequest(req as URLRequest)
    }
}

Does any one know whats happend? Why i can only show the files that i set on swift 3 and not the new ones added with the new version. Thanks a lot guys.

1
What is req? Which steps did you try to debug the code?Amin Negm-Awad
req is the variable request, the problem was that the files wasn`t copy to the "Copy Bundle Resources", thanks to ask and your help!Gabo MC
I wanted to know the value of req, because I saw the possibility that it is not found …Amin Negm-Awad

1 Answers

1
votes

From your question I understand that you are adding new pdf file... right?

If so... By default when a resource(images, pdfs, etc...) is added in Xcode 9, it is not getting added to Target.

If you add a new resource make sure, it is set to Target as well. Hope you know how to check whether a resource is added to Target. You can also verify whether a resource is added from the 'Copy Bundle Resources"