Problems with PDFKit

How to fix it?

Errors: "Cannot find type 'UIViewRepresentable' in scope" "Cannot find type 'Context' in scope" "Cannot find type 'Context' in scope"

I tried: Re-installed the Xcode Re-started computer

Great thanks.

import SwiftUI import PDFKit

struct PDFViewerView: UIViewRepresentable { var url: URL

func makeUIView(context: Context) -> PDFView {
    let pdfView = PDFView()
    pdfView.document = PDFDocument(url: self.url)
    return pdfView
}

func updateUIView(_ uiView: PDFView, context: Context) {
    // Update the view.
}

}

Xcode Version 15.0.1 (15A507)

I do not see anything wrong with the logic in the code you supplied. I see two possible formatting errors: importing the two frameworks on the same line and declaring the url property on the same line as the struct declaration.

Does the code build if you place the import statements on separate lines and the url declaration on its own line?

import SwiftUI 
import PDFKit

struct PDFViewerView: UIViewRepresentable { 

  var url: URL

  func makeUIView(context: Context) -> PDFView {
    let pdfView = PDFView()
    pdfView.document = PDFDocument(url: self.url)
    return pdfView
  }

  func updateUIView(_ uiView: PDFView, context: Context) {
    // Update the view.
  }
}
Problems with PDFKit
 
 
Q