One codebase, two Macs: Developer ID vs the App Store sandbox

Shipping the same archive app through two Apple front doors, and what each one costs me.

By · · Part of Files, Unwrapped: building a Mac archive app

There is a small ritual I use when I compare the two editions. I install both editions of Peel on the same Mac, open the same archive in each, and watch what happens. In one, a Finder window changes in place. In the other, a new window appears. The archive is the same, the engine is the same, and the files inside are the same. The only difference is which of Apple's two front doors the app came through.

That difference turns out to be a good way to learn what the sandbox really is.

Two doors

Peel ships in two editions from one set of sources. The direct edition is signed with a Developer ID, notarized, downloaded from my site, and updated with Sparkle. The Mac App Store edition is sandboxed, has its own bundle identifier, and is updated by the App Store. At the time of writing it is waiting for App Store review, so it is not live yet.

The sandbox is the whole story. The direct edition runs without it, so it can do things that depend on reaching outside its own container. The App Store edition runs with it, so it has to ask for access and cannot do some things at all. The two editions differ on purpose, and I keep a table of the differences in the repo so I do not forget which is which.

What the sandbox takes away

The sandboxed edition gives up three headline things.

The volume. In the direct edition, Peel carries an FSKit module meant to mount an archive as a read-only volume. I should be honest about that one: on the macOS version I am testing, the switch that lets third-party file system modules load does not stay on, for any module I have tried. So today, in both editions, "open like a folder" is done another way, described below. The FSKit module is in the direct build, and the sandboxed one does not include it at all.

The right-click menu. The direct edition has a Finder Sync extension, which adds a native context menu in Finder. The sandboxed edition does not ship it. It does keep the Services menu entries that an app can declare in its own Info.plist, so Control-click on an archive still offers Peel, but not the richer native menu, and not the installable workflows the direct edition offers.

Sparkle. The direct edition updates itself. The App Store edition cannot, and should not: Apple does that. The APP_STORE compile condition removes Sparkle, along with the Finder scripting and the service installer, so none of that code or those frameworks end up in the sandboxed bundle. A verification script checks that they are absent, because I would rather fail a build than ship a reviewer a surprise.

How "open like a folder" survives

The promise Peel makes is simple: double-click an archive and see what is in it, as if it were a folder. The sandbox does not let me keep every mechanism for that, but it lets me keep the promise.

The honest implementation is a browse volume. The engine extracts the archive into a cache folder, and Peel points Finder at that folder. The cache is reused only while the archive's modification time and size still match. In the sandboxed edition the folder is created next to the archive where Peel may already write, or otherwise in its own container, and then opened in Finder.

The visible difference is small. The direct edition can tell Finder to browse in the same window by sending Apple Events. The sandboxed one opens a new Finder window or tab. It is a slightly different feel, and the files inside look the same.

Alongside that, the sandboxed edition keeps Quick Look and Spotlight. Press Space on an archive and you see a list of what is inside, with a lock shown if the names are hidden behind a password. Spotlight can find a file by name inside TAR, 7z and RAR archives, among other formats. These are separate extension targets, compiled with the same condition, and each has its own bundle identifier that begins with the app's, which is a rule I learned from the build rather than from the documentation.

The sandbox, in practice

Most of the work is not the headline loss. It is the dozens of small things that stop working until you ask.

Entitlements. The app asks for as little as it can: read and write access to files the user chooses, a way to remember those choices, and access to Downloads, where archives most often live. No temporary exceptions, and a verification script fails the build if one appears.

Folder grants. A sandboxed app can read the file it was handed but not write to its folder. So before extracting, Peel checks whether it can write, and if it cannot, it asks once with an Open panel and keeps the answer as a security-scoped bookmark. People who grant their home folder are asked once and never again. Split and multi-volume archives need the same treatment, because the sandbox gives me only the first part unless the user allows the folder that holds the rest.

The engine helper. Peel's work is done by a command-line helper that is embedded in the app. The helper has to run inside the same sandbox, so it is signed with the app-sandbox entitlement and an inherit entitlement, which means it gets the app's access and nothing else. That small pair of entitlements took me longer to get right than any feature.

Privacy manifests. Every bundle Peel ships carries a privacy manifest, in both editions, including the extensions. Without them the App Store upload is rejected. Each manifest declares no tracking and no collected data, plus the required-reason APIs that bundle actually uses, such as file timestamps and disk space. When the code starts using a new API from Apple's list, the manifest has to change too, and a script fails if one is missing or declares anything it should not.

Purchases. Peel is free to open and extract. Peel Pro is a one-time US$29.99 unlock, and in the App Store edition it is an in-app purchase through StoreKit, coming with the Mac App Store release, rather than my own checkout. The sandboxed bundle contains no link to the site's checkout, and a check enforces that.

Why the direct edition still exists

If the sandboxed edition does the core job, why keep the other one?

Because the direct edition is the version I get to build without asking permission. It has the native Finder menu, it updates itself on my schedule, it browses in the window you already have open, and it is where the FSKit work lives, ready for the day the platform lets a third-party module load reliably. It also carries the command-line tool. The direct edition is the full-power version, and I would rather keep one place where I can build the whole idea.

I expect the App Store edition to be where most people meet Peel, and I want it to be good in its own right, not a diminished copy. It also has to stand alone: review notes, a demo archive, a clear explanation of each entitlement. The first review did not go smoothly (a story I've saved for its own post), but the lesson it drove home belongs here: the sandboxed edition has to explain itself to someone who has never seen it before, because that someone includes the reviewer.

The tax

Supporting both editions is not free, and I would be lying if I said otherwise.

Every feature gets two questions: does it work in the sandbox, and does it work without it? Some code sits behind a compile condition, which means some code is built in only one edition and tested in only one. Release checks run twice. Two bundle identifiers means two sets of Keychain items, two sets of permissions, two sets of screenshots. A bug can live in one edition and not the other, and I have to remember which.

The discipline that keeps it manageable is a single codebase, one table of differences, and scripts that check each build against the rules rather than trusting my memory. The less I rely on remembering, the less the second edition costs.

What I would say to myself at the start

I used to think of the sandbox as a restriction on the app. I now think of it as a specification. It forces you to say, in entitlements and in grants, exactly what your app needs and why. Writing that down made the direct edition better too, because I could finally see which of its powers were essential and which were there only because nothing had stopped them.

Two doors is more work than one. I would still choose two. One of them gets Peel to the people who only want an app that works, and the other gets me a place to keep building the version I actually want.

Peel is free for macOS 13 or later. Get Peel, or install it with brew install --cask snackstudio/tap/peel.

Next in the series: Rejected: a Mac App Store review from start to resubmission