Sleeping through a decade of Cocoa: Retrospective from modernizing an old Mac app

A few years ago since I started using Macs more often, one annoying thing I dealt with was using my local music library. My usual solution was to just drag files from the file manager to a music player, but this wasn’t as nice on macOS (due to i.e. SMB latency). However, I did have a Subsonic server, which provides a nice music streaming server, complete with an API for clients to use for things like phones. Why not use this on my laptop too?

Of course, if I bought a Mac, I’m not going to put up with bad cross-platform solutions that suck everywhere, when I can instead run bad native software that sucks uniquely for my platform of choice. However, there weren’t too many clients available on Mac. Mostly all of them were unmaintained and had been abandoned in the Snow Leopard era. One of them was Submariner, and it was open-source after the developer (RafaĆ«l Warnault) had stopped working on it. Writing my own seemed a bit daunting with no background, but what if I used the Submariner codebase, and started from there?

Now I’ve been maintaining Submariner for almost two years at this point (it even has a minimal website), adding features and mostly just focusing on modernizing the codebase. It’s been an interesting experience as my first Objective-C/Mac project. A lot of the lessons of modernizing legacy code are universally applicable, but I’ve learned a lot about the specifics of Apple platforms and how they compare. This article aims to be both a retrospective on what I had to learn, what I had to do, and the lessons I took from it, including a comparison of what the development culture is like between platforms.

Continue reading

Restoring images without the futility of Disk Utility

I was trying to put a Mac OS X 10.6 image onto a USB stick to install on another system. To do this, I attempted to do it from a Mac running 13.6 and failed with a message like this when restoring the image to the partition:

Could not validate source - Invalid argument
The operation couldn't be completed. (OSStatus error 22.)

It turns out that Disk Utility is pretty broken at this. What you’re better off doing is using asr. This utility is what Disk Utility does under the covers anyways.

Continue reading

Why Macs don’t have games, or: Why Vulkan or the Game Porting Toolkit isn’t going to save you

Recently, one of Apple’s focuses at the latest WWDC keynote has been gaming. Two important pillars for this are an HLSL to Metal shader compiler, and the Game Porting Toolkit. Both are important, since HLSL is dominant for shaders in the industry, but the GPTK has become popular outside its intended target audience, with many videos with end-users instead of developers using it to try the latest AAA games. This has led to a lot of speculation online about what obstacles exist for game developers looking to port their games to Mac. What challenges actually matter?

(This is a bit of a rougher post, more addressing common points I see from Mac gamers on why they don’t have games. I’m not a game developer or expert in 3D graphics APIs, but I do keep up with the space. There is also some Kremlinology on Apple, but that’s inevitable considering the secrecy.)

Continue reading

Opening System Settings/Preferences to a specific app’s notification settings

If you need to open System Settings (formerly System Preferences) to a specific preference pane, there’s a URL scheme for that. However, some panes seem to take options for opening specific things. In my case, I wanted open the notifications pane to a specific app. The system Maps application can already do this, so I popped it open in a disassembler and learned the secret – ?id=(app bundle ID). For example, opening the following URL will open the notifications settings for Firefox:

x-apple.systempreferences:com.apple.preference.notifications?id=org.mozilla.firefox

Debugging an x86 application in Rosetta for Linux

Rosetta on Linux has been great for me, as someone who switched to an ARM Mac and sometimes develops in a VM. This is because my dayjob often involves debugging a proprietary database driver that only has x86 and PowerPC versions available for Linux, not 64-bit ARM. However, while Rosetta can make it easy to run x86 binaries, it’s not as obvious how to debug them. If you naively try running GDB on your x86 program, you get errors like:

warning: `/lib64/ld-linux-x86-64.so.2': Shared library architecture unknown is not compatible with target architecture aarch64.
warning: `/lib64/ld-linux-x86-64.so.2': Shared library architecture unknown is not compatible with target architecture aarch64.
Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0x66ec48

This is because you’re attaching to the Rosetta binary, which causes all sorts of confusion for GDB. Turns out, Rosetta does actually have a way to handle this.

Continue reading

Building a static GraphViz for macOS

Note: This is a very old post from 2020 I had sitting in my drafts. I figured I would publish it in case it was useful for someone else. Notably, this predates Apple Silicon, so yo would want to build another version that’s ARM and use lipo to make a universal binary. This is left as an exercise to the reader.

I recently had the need for building GraphViz without any external dependencies other than what comes with macOS, as part of an application calling into it. While on Windows, I used their provided binaries, I was on my own for macOS since I wasn’t willing to ship half of Homebrew with my application. Instead, I took a simpler way.

Continue reading

Potemkin villages and the autocracy of design

tl;dr: As much as I respect the efforts undertaken by groups like Gnome and elementary, I have to wonder if what they’re building is barely enough, and provides an illusion of substance.

There’s been a lot of effort spent on the Linux desktop. The groups I respect the most on this front are Gnome and elementary, due to their focus on UX design and trying to do new things. While Gnome has been controversial due to their design and stance towards design, I think a lot of the controversy on that front is unmerited (i.e Gnome’s design isn’t actually appropriate for tablets as much as the peanut gallery thinks). I appreciate that someone is trying to do something other than “Windows 98 stomping on a human face, forever”, and it’s what I use on my desktop. Controversial for other reasons (also unmerited, a man’s gotta eat; that desktop won’t happen with getting paid in exposure), elementary’s design has been considered very nice (often making it recommended for “my first distro”), if a bit derivative at first glance. What makes it more interesting in the morass of many OSS UX clones is UX as a priority/value (instead of something that’s just there) and iterating on existing UX. Sometimes it works out, doesn’t it doesn’t, but I respect the attempt at trying something new and seeing if it’s better.

However, I wonder if what they’re doing is enough. They have a desktop, many components of that desktop, and human interface guidelines (elementary, Gnome); all components you need. What I think is missing is the substance. Where’s the ecosystem of applications that embrace the HIG, and how does the intricacies of the of the environment come into play for complex applications and situations?

Continue reading

Files with accents not showing from an SMB share on macOS

I recently had an issue where some files with accents were showing, but not all of them. If none of them were showing, I might have assumed an encoding issue, but it’s clear something else was at play here. This was pretty annoying when I wanted to play a specific song.

As it turns out, on macOS, it’s almost certainly a Unicode normalization issue, where Apple is (unnecessarily) strict about Unicode. I seem to keep running into these issues on macOS – I first into it trying to notarize a zip file. Luckily, there’s a tool that can handle this for you.

Continue reading

Notes with the Parallels Beta on Apple Silicon

QEMU recently gained Apple Silicon hypervisor support. That was pretty damn cool for the first few weeks of M1 in people’s hands. Even without any optimizations, Windows 10 on M1 outclasses the Surface Pro X and even my Ryzen gaming desktop. Unfortunately, that didn’t include 3D acceleration (though virtio-gpu is now a thing for 2D).

Luckily, Parallels has ported their virtualization software to M1. It’s incredibly janky (and certainly deserving of a technical preview because of that!), but shows a lot of promise, complete with D3D11 support for games. Unfortunately, it requires some hacks to get running stable, but it’ll work fine after that.

Continue reading

“xcrun altool” not found on macOS

I needed to attempt a notarization of a Mac app (currently still in the middle of that long story), but I wasn’t using Xcode, so I had to run tools manually. Unfortunately, I couldn’t use xcrun altool, as it couldn’t find the command. I had upgraded the version of Xcode I was using, so I guess I had some stale links somewhere. Running xcode-select -r did the trick and fixed it.