Posts

Post not yet marked as solved
1 Replies
97 Views
I'm trying to create a custom Quick Look preview on macOS. I've found the Quick Look Preview Extension target, which is brilliant, and does most of the 'heavy' lifting, but I've run into a few problems. I'm implementing a preview for MIDI files (which has been missing since 2009...) using AVMIDIPlayer. The player keeps playing when the file is no longer selected! What's the mechanism for fixing that? Some sort of check that the view exists..? I notice that the OS preview for audio files has a different interface for the Finder's preview column and for the QuickLook 'pop-up' window. Again, I can't see how you define different views for those two environments. Is there any documentation that's specifically "Mac"? I can only find iOS stuff. (Same for third-party tutorials.)
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
1 Replies
58 Views
I've added a new target to my macOS project -- a quicklook preview extension. Now, when I try to build the project, I get a dialog saying "Select App to Run". QuickLook Simulator launches, but my app doesn't build -- by which I mean it doesn't attempt to build. What do I have to do to build the whole thing?
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
2 Replies
149 Views
I have a real problem trying to get to grips with the whole Optionals/wrapping thing, and associated type issues. Here's my code: import Quartz import Foundation func listFilters() -> Void { let theFilters = QuartzFilterManager.filters(inDomains: nil)! for eachFilter in theFilters as! [QuartzFilter] { print(eachFilter.localizedName()!, ":", eachFilter.url().path) } } listFilters() So, in the first line of the function, I have to explicitly force unwrap the result of the method that returns a list of QuartzFilters. (Why?) The very next line, I have to force them to be of type QuartzFilters, (because why wouldn't the method return the actual type of thing that they are?) And then on the third line, I still have to force unwrap one of the properties of something that I've already unwrapped (otherwise I get optionals), but not the other one. Yes, I understand it's all about trying to prevent a null condition, but nearly everything is never null. Even if I use if let on the first line, I'm still unwrapping stuff inside that if.
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
512 Views
Since Big Sur, the printtool process has been sandboxed, with the result that it's now so secure, it can't do anything. As a consequence, PDF Services (items in ~/Library/PDF Services) no longer work. An alias to a folder outside the user domain, such as /Users/Shared/, no longer saves the PDF file to that location. Shell scripts, python, and even compiled Swift binaries no long run. Even Automator Print plug-ins no longer function. Adding printtool to Full Disk Access doesn't work either. ("If in doubt, add the process to Full Disk Access.") The ability to process PDFs directly from the print dialog goes back to Tiger (I think) and has been massively useful for years. Yes, I suppose some malware could save a script to the user PDF Services folder, and then some unwitting user could run it from the print dialog, but.... At the very least, some new documentation about how PDF Services are now supposed to work would be crucial.
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
163 Views
Apple seems to have archived its documentation for making PKG packages, and PackageMaker hasn't been seen since 2012. Are packages deprecated, or are there new ways for creating them?
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
329 Views
Now that CUPS backends, filters and PPDs are deprecated, I'm trying to set up a print to file queue using ippeveprinter. But I can't get it to work. Anyone know anything about it? I've tried: ippeveprinter -D file:///Users/Shared/Print/Out -F application/pdf -c /usr/local/bin/pscommand.sh myprinter and then created a shell command that runs: cupsfilter $1 I've tried it without the -c flag as well. Sometimes I've produced .prn files, and occasionally .urf files (but without changing anything I've also got zero length files). But I just can't get a PDF into my destination folder.
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
I'm not sure whether this is a bug in PDFKit, or something wrong with my implementation of it. I'm creating PDFOutlines (a Table of Contents) programmatically to an existing PDF file using python.The code 'appears' to work: the ToC is shown in Preview's sidebar, and in Acrobat's Bookmarks pane; and in other PDF readers. However, when I Preflight the PDF in Acrobat, I get syntax errors flagged, which show that there's something mad going on in the data. For three PDFOutlines, I get the following:2 0 obj << /First 57 0 R /Last 58 0 R >> endobj 58 0 obj << /Prev 59 0 R /Count 0 /Title (Page 3) /Dest [ 31 0 R /XYZ 0 842 null ] /Parent 60 0 R >> endobj 60 0 obj << >> endobj 59 0 obj << /Parent 61 0 R >> endobj 61 0 obj << >> endobj 57 0 obj << /Dest [ 4 0 R /XYZ 0 842 null ] /Count 0 /Title (Page 1) /Next 62 0 R /Parent 63 0 R >> endobj 63 0 obj << >> endobj 62 0 obj << /Prev 64 0 R /Count 0 /Title (Page 2) /Dest [ 25 0 R /XYZ 0 842 null ] /Next 65 0 R /Parent 61 0 R >> endobj 65 0 obj << /Prev 59 0 R /Count 0 /Title (Page 3) /Dest [ 31 0 R /XYZ 0 842 null ] /Parent 60 0 R >> endobj 64 0 obj << /Parent 63 0 R >> endobjFor anyone not familiar with the insides of PDF: I have the Outline for Page 3 appearing twice; and each Outline is pointing to a different, blank Parent, instead of object number 2. Acrobat flags objects 60, 61, 63 as missing Parent and Title fields; 64 and 59 lack Title fields only. Correct syntax should be the 3 Outlines having object 2 as their Parent, and none of the other objects being there.Here's my code in python:def getOutline(page, label): # Create Destination myPage = myPDF.pageAtIndex_(page) pageSize = myPage.boundsForBox_(Quartz.kCGPDFMediaBox) x = 0 y = Quartz.CGRectGetMaxY(pageSize) pagePoint = Quartz.CGPointMake(x,y) myDestination = Quartz.PDFDestination.alloc().initWithPage_atPoint_(myPage, pagePoint) myLabel = NSString.stringWithString_(label) myOutline = Quartz.PDFOutline.alloc().init() myOutline.setLabel_(myLabel) myOutline.setDestination_(myDestination) return myOutline if __name__ == "__main__": pdfURL = NSURL.fileURLWithPath_(infile) print pdfURL myPDF = Quartz.PDFDocument.alloc().initWithURL_(pdfURL) print myPDF if myPDF: # Create Outlines. Add the Page Index (from 0) and label in pairs here: myTableOfContents = [ (0, 'Page 1'), (1, 'Page 2'), (2, 'Page 3') ] allMyOutlines = [] for index, outline in myTableOfContents: allMyOutlines.append(getOutline(index, outline)) # Create a root Outline and add each outline rootOutline = Quartz.PDFOutline.alloc().init() for index, value in enumerate(allMyOutlines): rootOutline.insertChild_atIndex_(value, index) myPDF.setOutlineRoot_(rootOutline) myPDF.writeToFile_(outfile)There's a function at the top which creates an outline from a label string and page number. Each outline gets put into a dict, and then inserted as a Child of the root Outline. Am I doing it wrong, or is it a bug?
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
1 Replies
335 Views
Pages, Numbers, KeyNote use a sheet dialog for choosing options when exporting graphics. Is that using a public API, or is it just a bit of bespoke code? I notice a few other apps having similar sheets.
Posted
by benwiggy.
Last updated
.
Post marked as solved
3 Replies
401 Views
I want to create an application that does nothing, except 'hand-over' to another application. So double-clicking on the app launches another app; and double-clicking on the app's files opens them in the other app. Why? Because I want to set custom file icons to a particular file type. So I'm using a dummy app as the 'default' app for the file type, before handing to the real app. In Mojave, I can do this: create a boilerplate application in Xcode, add the document type and icons; then switch out the app's binary for a hard link to the binary of the app I want. However, this doesn't work on Catalina , for 'security reasons'. <rolls eyes> I even tried re-signing my app with the hard link in the bundle, but that still doesn't work. The app just crashes on launch. Is there another way that I can do this? Or are such things forbidden? I've tried creating an Automator or AppleScript application that just opens the target app, passing the documents to it, but I can't work out how to modify the Info.plist without getting a 'No Entry' sign on the app. PS: How do you browse through these forums? I'll be amazed if anyone reads this.
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
305 Views
Apple's documentation on creating Application Extensions shows Xcode offering project templates for Application Extensions. https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionCreation.htmlThese no longer seem to be in Xcode when I start a new project. Has Apple moved the goalposts again, or is there a place where I can download a template?Thanks
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
310 Views
It seems that the PDFAnnotation classes have all been deprecated, and that we're now supposed to use PDFAnnotationSubtype instead.Any documentation on how? ..... tumbleweed ....
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
2 Replies
480 Views
I'm not 'enrolled in the Apple Developer Program" (i.e., I'm not paying Apple a sub.) Does this mean I can't notarize my apps? I tried to follow the instructions, but when I Upload my app to Validate it, I get an error, saying that my Team is not enrolled.My Team is created from my Apple ID, and Signing Certificate is set to "Development".Is that sufficient to create an app that GateKeeper will let through the gate?
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
0 Replies
359 Views
Some apps contain "Library files" like QuickLook generators or Spotlight importers, which are stored in locations such as theApp.app/Contents/Library/Spotlight/ or theApp.app/Contents/Library/QuickLook/, which essentially makes them available to the OS, as if they were installed in those Library subfolders. (e.g. OmniOutliner, OmniGraffle.)I want to similarly add a Quartz Filter to my MacOS app, which would otherwise go in Library/Filters, so that the app (at least) has access to that filter as if it were actually installed, rather than just having it as bundled 'content'.I can't see any specific method in Xcode's "Add Frameworks, Libraries and Embedded Content", and the "New Target" method of adding a Spotlgiht importer doesn't offer a generic Library item protocol. Does anyone know how it might be done?
Posted
by benwiggy.
Last updated
.
Post not yet marked as solved
4 Replies
592 Views
I've been trying to understand how to use Cocoa Bindings. There seems to be three ways: key-value observing; Notifications; and Bindings in Interface Builder.The purpose of bindings is supposedly to avoid writing lots of glue code and make it easy to transfer information between the model, the view and the controller -- but using Notifications and key-value observing seems to involve considerable amounts of code.Setting bindings in Interface Builder would seem to be the simplest way, though to me the most oblique. Could someone talk me through, or point me to some useful information about how to use this? Essentially, whenever the user triggers an IBAction, it has to do view things and document things. (e.g. get view status info; alter document; reset view)The View and Window objects only seems to offer Binding to the View Controller. So how do I bind the document to the View?I've looked at Apple's documentation, and the RayWenderlich site tutorials. Apart from a lack of code portability, is there really any reason why I shouldn't just define the relevant ViewController in the Document.swift file, and define the relevant Document in the ViewController.swift file, and then just call methods in each one?
Posted
by benwiggy.
Last updated
.
Post marked as solved
31 Replies
3.5k Views
I'm creating a MacOS document-based app in Swift. When running the app, if I make modifications to the document, and then select "Revert to Saved", I get a dialog asking me if I want to revert the document, losing current changes, but if I click on "Revert", nothing happens. The document keeps its changes.Furthermore, after clicking Revert, the document behaves as if there are no changes -- the titlebar icon is not grey; and the window closes without asking to save changes (I'm not using Autosave). It's like ChangeCount or isDocumentEdited have been reset.If I don't select Revert, then closing the document's window with unsaved changes brings a dialog asking to save.Apple's documentation for .revertToSaved reads as follows:The default implementation of this method presents an alert dialog giving the user the opportunity to cancel the operation. If the user chooses to continue, the method ensures that any editor registered using the Cocoa Bindings NSEditorRegistration informal protocol has discarded its changes and then invokes revert(toContentsOf:ofType:). If that returns false, the method presents the error to the user in an document-modal alert dialog.This suggests to me that it should work without needing to be overridden. Any idea why this is happening? Do I need to override the revert method to load the data back from disk? I've not yet sorted out Undo for the app, which might be relevant. But I am using ChangeCount to check whether edits have been made.
Posted
by benwiggy.
Last updated
.