Alua-Kinzhebayeva / iOS-PDF-Reader

PDF Reader for iOS written in Swift
MIT License
533 stars 150 forks source link

Use of unresolved identifier 'PDFDocument' #53

Closed TCOA closed 7 years ago

TCOA commented 7 years ago

Admittedly new to Xcode and Swift 3 and looking for a PDF solution that works, I found this framework.

However, following the instructions (and finally figuring out that the code given should be in the viewDidLoad(), I still get the error "Use of unresolved identifier 'PDFDocument'"

` override func viewDidLoad() { super.viewDidLoad()

let remotePDFDocumentURLPath = "http://devstreaming.apple.com/videos/wwdc/2016/201h1g4asm31ti2l9n1/201/201_internationalization_best_practices.pdf"
let remotePDFDocumentURL = URL(string: remotePDFDocumentURLPath)!
let document = PDFDocument(url: remotePDFDocumentURLPath)!     <<<=== get error here
let readerController = DocViewController.createNew(with: document)
navigationController?.pushViewController(readerController, animated: true)
}

`

This seems a basic install problem, though the instructions are not clear.

I looked through the issues and found one that said to link the framework in Embedded Binaries - seemed to be logical it would relate, but that didn't help.

I've tried several ways to read PDFs and nothing has worked, so I really do hope this one will do what it says - it certainly looks good.

ranunez commented 7 years ago

The install instructions assumes one is already familiar with dependency managers such as Carthage or Cocoapods. Please do a quick tutorial or two of Carthage and/or Cocoapods to understand how to integrate external libraries such as this into your application.

TCOA commented 7 years ago

I've installed 19 external libraries and every one (from large groups to small - Alamofire, SwiftKeychainWrapper, Mapbox, Firebase, etc.) have all had an 'import' command associated with the Cocoapods install and use - and I have had no issues with any of them.....

So, it seems clear that "such as this one" really isn't..... - in my, admittedly new, though not inexperienced, use of Cocoapods.

I had tried "import PDFReader", though it seems that is not correct, nor "import iOS-PDF-Reader"..... - nor trying to get additional information/help from the developer..............

ranunez commented 7 years ago

If you checkout the demo project, you can see a working implementation using Carthage, but the same would apply for Cocoapods

TCOA commented 7 years ago

For others that are somewhat new to all this and that may wish to use this library, here is the Swift 3 working code (I don't know why it didn't work before, but it works with this code....)

` import UIKit import PDFReader

class DocViewController:UIViewController { override func viewDidLoad() { super.viewDidLoad() let remotePDFDocumentURLPath = "YOUR_URL_HERE" let remotePDFDocumentURL = URL(string: remotePDFDocumentURLPath)! let document = PDFDocument(url: remotePDFDocumentURL)! let readerController = PDFViewController.createNew(with: document) navigationController?.pushViewController(readerController, animated: true) } } ` It works quite nicely and is even 'pretty' (one of the requirements actually stated by the folks asking me to create this app for them..... :)

However, I do have one issue (not directly related to the library, though I'm not sure how to fix it.....

I'm accessing this controller through a seque controller (using Eureka) and when going 'Back', I get a blank page instead of back to the main page.

Likely can be fixed by the 'custom back button' - I'll fight with that, though otherwise, this is really a nice presentation of PDFs (sorry about harsh comments before - I'm sure you know how frustration sometimes sets in when trying to get a project out.......)