swift3 - Not getting file URL from bundle -


i loading pdf file in pdfview unable pdf file url bundle.

please check below code :

let pdfview = pdfview(frame: self.view.bounds) let myfilename = "sample" guard let url = bundle.main.url(forresource: myfilename, withextension: "pdf") else {          return } pdfview.document = pdfdocument(url: url)  self.view.addsubview(pdfview) 

every time getting nil in url.

edit :

here project window:

enter image description here

am making silly mistake ?

please guide me.

thanks in advance.

i got problem not sure it's in latest xcode in xcode 9.5(beta) while adding external file in project , select bundle target still not adding bundle.

solution :

you need click on file want add target bundle , check manually property window.

please check below screen shot more detail.

while adding file project have checked still not adding in selected target.

enter image description here

now need check target , working expected.

enter image description here

not sure bug or new update in latest xcode.

but problem solved.

thanks.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -