Swift Cocoa: PrintOperation() with Sonoma does not work

I have a Swift Coco program taht print a NSView. It work perfectly fine in Monterey but does show the print panel in Sonoma. I cannot find the problem. Here are the 4 errors: Failed to connect (genericPrinterImage) outlet from (PMPrinterSelectionController) to (NSImageView): missing setter or instance variable Failed to connect (otherPrintersLabel) outlet from (PMPrinterSelectionController) to (NSTextField): missing setter or instance variable Failed to connect (localPrintersLabel) outlet from (PMPrinterSelectionController) to (NSTextField): missing setter or instance variable Failed to connect (genericPrinterImage) outlet from (PMPrinterSelectionController) to (NSImageView): missing setter or instance variable

 func createPrintOperation() {
        let printOpts: [NSPrintInfo.AttributeKey: Any] = [
            .headerAndFooter: false,
            .orientation: NSPrintInfo.PaperOrientation.portrait
        ]
        let printInfo = NSPrintInfo(dictionary: printOpts)
        printInfo.leftMargin = 0
        printInfo.rightMargin = 0
        printInfo.topMargin = 0
        printInfo.bottomMargin = 0
        printInfo.horizontalPagination = .fit
        printInfo.verticalPagination = .automatic
        printInfo.isHorizontallyCentered = true
        printInfo.isVerticallyCentered = true
        printInfo.scalingFactor = 1.0
        printInfo.paperSize = NSMakeSize(612, 792) // Letter size

        // Create a print operation with the view you want to print , myPrintView is a NSView
        
        let printOperation = NSPrintOperation(view: myPrintView, printInfo: printInfo)
        
        // Configure the print panel
        printOperation.printPanel.options.insert(NSPrintPanel.Options.showsPaperSize)
        printOperation.printPanel.options.insert(NSPrintPanel.Options.showsOrientation)
        
        // Set the job title for the print operation
        let jobTitle = fact.nom_complet_f.replacingOccurrences(of: " ", with: "")
        printOperation.jobTitle = jobTitle

        // Run the print operation
        printOperation.run()
    }

I am pretty sure the four errors have nothing to to with your printing problem. They seem to be an issue inside the printer dialog, but nothing which prevents you from printing.

Are you sure myPrintView is valid?

Swift Cocoa: PrintOperation() with Sonoma does not work
 
 
Q