0

I'm trying to use QuickLook in OSX. There are several problems with my sample code:

1) It does not preview the image.

2) I get these errors:

2019-05-05 08:35:17.898276+0100 QuickLook[13561:1658693] [default] Unable to load Info.plist exceptions (eGPUOverrides) 2019-05-05 08:35:17.963612+0100 QuickLook[13561:1658651] [General] -[QLPreviewPanel setDelegate:] called while the panel has no controller - Fix this or this will raise soon. See comments in QLPreviewPanel.h for -acceptsPreviewPanelControl:/-beginPreviewPanelControl:/-endPreviewPanelControl:. 2019-05-05 08:35:17.963759+0100 QuickLook[13561:1658651] [General] -[QLPreviewPanel setDataSource:] called while the panel has no controller - Fix this or this will raise soon. See comments in QLPreviewPanel.h for -acceptsPreviewPanelControl:/-beginPreviewPanelControl:/-endPreviewPanelControl:. 2019-05-05 08:35:18.050123+0100 QuickLook[13561:1658651] [Layout] Unable to simultaneously satisfy constraints: ( "", "", " (active)>", "", "" )

Will attempt to recover by breaking constraint

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger. 2019-05-05 08:35:18.050436+0100 QuickLook[13561:1658651] [Layout] Unable to simultaneously satisfy constraints: ( "", "", " (active)>", "", "" )

Will attempt to recover by breaking constraint

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.

Here is the code:

import Cocoa
import Quartz

class ViewController: NSViewController,  QLPreviewPanelDataSource, QLPreviewPanelDelegate {

    override func viewDidLoad()
    {
        if let sharedPanel = QLPreviewPanel.shared()
        {
            sharedPanel.delegate = self
            sharedPanel.dataSource = self
            sharedPanel.makeKeyAndOrderFront(self)
        }
    }

    func numberOfPreviewItems(in panel: QLPreviewPanel!) -> Int {
        return 1
    }

    func previewPanel(_ panel: QLPreviewPanel!, previewItemAt index: Int) -> QLPreviewItem! {
        let url = URL(fileURLWithPath: "myimage.jpg")
        return url as QLPreviewItem
    }
}

Please could anyone tell me what am I doing wrong?

iphaaw
  • 6,764
  • 11
  • 58
  • 83
  • Is this the same issue: [swift QLPreviewPanel crash — NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints](https://stackoverflow.com/questions/54363591/swift-qlpreviewpanel-crash-nsconstraintbasedlayoutvisualizemutuallyexclusivec)? – Willeke May 05 '19 at 12:36
  • No it's different. Thanks. – iphaaw May 06 '19 at 14:52
  • Why is it different? Did you try the suggestions in the errors? – Willeke May 06 '19 at 15:53
  • See [Unable to load Info.plist error Xcode 10 under macOS 10.14 Mojave](https://stackoverflow.com/questions/52507950/unable-to-load-info-plist-error-xcode-10-under-macos-10-14-mojave) – Willeke May 06 '19 at 21:29
  • Take a look at sample code [QuickLookDownloader](https://developer.apple.com/library/archive/samplecode/QuickLookDownloader/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009082). It made me understand how to use `QLPreviewPanel`. – Willeke May 06 '19 at 21:30
  • I tried to reproduce the constraints errors but I can't. I get other weird errors, exceptions and warnings but no complaints about constraints. – Willeke May 06 '19 at 22:12

0 Answers0