Unable to open mach-O at path: default.metallib Error:2

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()
}

Accepted Reply

Hi, I don’t think you are doing anything wrong. This seems like a bug either in the PDFKit or SwiftUI framework. It’s probably ok for you to ignore it.

  • Thank you very much for your help! :)

Add a Comment

Replies

Hi, I don’t think you are doing anything wrong. This seems like a bug either in the PDFKit or SwiftUI framework. It’s probably ok for you to ignore it.

  • Thank you very much for your help! :)

Add a Comment

See On Log Noise for the extended version of shaderguy’s answer.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thank you for your answer! :)

Add a Comment