Hey there,
I am quite new to SwiftUI and currently trying to implement a pdf file into my app. When run the app on my iPhone the pdf file opens without any problems but I always get this Error:
Unable to open mach-O at path: default.metallib Error:2
I do not actually understand the code completely I found on multiple websites, but what am I doing wrong? I attached my used code.
Thanks for your help!
Laurin
import PDFKit
struct PDFKitView: UIViewRepresentable {
let pdfDocument: PDFDocument
init(showing pdfDoc: PDFDocument) {
self.pdfDocument = pdfDoc
}
func makeUIView(context: Context) -> PDFView {
let pdfView = PDFView()
pdfView.document = pdfDocument
pdfView.autoScales = true
return pdfView
}
func updateUIView(_ pdfView: PDFView, context: Context) {
pdfView.document = pdfDocument
}
}
struct Hypoglykaemie: View {
let pdfDoc: PDFDocument
init() {
let url = Bundle.main.url(forResource: "hypoglykaemie", withExtension: "pdf")!
pdfDoc = PDFDocument(url: url)!
}
var body: some View {
PDFKitView(showing: pdfDoc)
}
}
#Preview {
Hypoglykaemie()
}