Including Services in contextual menus in SwiftUI

Screenshot of the good Services submenu (as found in the application menu), with more options, app icons, and better grouping.

SwiftUI provides a way to provide a contextual menu for a view, with contextMenu(menuItems:) and friends, but it requires you to manually specify the entire contents of the contextual menu. That means it does not include the standard Services submenu. A brief history of Contextual Menus Contextual menus were introduced [to the Mac] in 1997… Read more

Hiding SwiftUI views

There are several ways to hide a SwiftUI view, although they don’t all agree on what it means to hide the view. Do you want it to be invisible, or actually not there? To make it invisible you need only set its opacity to zero or use the hidden modifier. But the view will still… Read more

Proactive Peek & Reveal on Edge Hover

Screen capture video showing an attempt to grab the scroll handle and how it's foiled by Proactive Peak stealing the click away to resize a previously-closed sidebar.

These are two misfeatures that appeared in macOS Sonoma (I believe). They are where a closed sidebar forces its way back into view temporarily, if the mouse comes to rest near the relevant edge of the window. It’s easy to see how some UI designer thought this was a good idea. Surely if you move… Read more

SwiftUI drag & drop does not support file promises

SwiftUI doesn’t offer anything equivalent to NSFilePromiseProvider, i.e. to write data to the drop destination. You have to ditch SwiftUI and use AppKit’s drag & drop APIs instead. FB13583826. Is that it? I know that’s not a very helpful in some sense, but I wasted days trying to figure out how to implement this very… Read more

Creating files safely in Mac apps

Creating a file is a pretty basic and conceptually simple task, that many applications do (whether they realise it or not – library code often does this too, at least for temporary files such as caches or for communicating between programs). So you’d think it’d be trivial to do correctly. Alas, it is not. ☝️… Read more

Reminder: macOS system frameworks binaries are hidden (since Big Sur)

Every now and again I’ll go to do something really innocuous with an Apple framework, like disassemble it in Hopper or check the link headers. And every. single. time. I forget that Apple did some really weird shit in Big Sur, and removed the binaries. $ ls -lh /System/Library/Frameworks/AppKit.framework/Versions/Current/AppKit ls: /System/Library/Frameworks/AppKit.framework/Versions/Current/AppKit: No such file or… Read more