Fixing the Mastered for iTunes Droplet

Sleep Studies, the band I play with, is in the process of finishing up our next EP. One of the (many) things I’m neurotic about is making sure the masters will translate as well as possible. I’ve written about how I use afclip to examine the master audio files for headroom; another thing I do is run the masters through the Apple’s Master for iTunes Droplet. This is distributed as part of the Mastered for iTunes program.

The Master for iTunes Droplet accepts your lossless files and returns .m4a files that mirror the files the iTunes backend will generate, so you can preview what your content in the store will sound like.

Well, it used to do this until Mac OS X 10.10 Yosemite was released.

The droplet is just a wrapper around an AppleScript file, and it’s easy to examine the script by dragging the entire droplet to the Script Editor application. The problem, it turns out, is just a trivial bug. On lines 62 and 109 you’ll find this chunk of code:

set systemVersion to system version of (get system info)
if systemVersion is less than "10.6" then
log ("ITUNESMASTERINGDROPLET: incompatible system version")
display alert SYSTEM_CHECK_ERROR_TITLE message SYSTEM_CHECK_ERROR_MESSAGE as warning buttons {CANCEL_BUTTON_TITLE} default button 1
log ("ITUNESMASTERINGDROPLET: shutting down")
error number -128
end if

It’s the if systemVersion is less than "10.6" then part that is troublesome — this is just a string comparison, not a numeric comparison. Starting with Yosemite (10.10), this conditional started doing the wrong thing. “10.10” is in fact less than “10.6” when comparing as strings. The fix is pretty easy, too. The incomparable Michael Tsai laid out a solution on Stack Overflow, which I’ve implemented here:

set systemVersion to system version of (get system info)
considering numeric strings
set systemVersionNewEnough to systemVersion ≥ 10.6
end considering
if systemVersionNewEnough is false then
log ("ITUNESMASTERINGDROPLET: incompatible system version")
display alert SYSTEM_CHECK_ERROR_TITLE message SYSTEM_CHECK_ERROR_MESSAGE as warning buttons {CANCEL_BUTTON_TITLE} default button 1
log ("ITUNESMASTERINGDROPLET: shutting down")
error number -128
end if

While I was at it, I wanted to fix the other issue with the Apple-distributed version of the droplet: it isn’t code signed. Because of this, when you download the droplet, Gatekeeper informs you that the application can’t be run.

Sal Soghoian’s MacOSXAutomation site has instructions for signing AppleScript Droplets. They’re easy to follow — the only snag I ran into was that I tried to use my iPhone developer certificate to sign the droplet, and that doesn’t help with Gatekeeper. I had to request a new “Developer ID Application”1 certificate to get things working.

With that, the version of the droplet linked below includes fixes for:

Droplet returning an error on Mac OS X 10.10 and later

Gatekeeper returning an issue with an unknown developer

I’ve filed a bug report with Apple reflecting these issues — it would be ideal if they fixed the versions they’re distributing. It’s rdar://30067799 if you’re interested in reading it.

Download the fixed Master for iTunes Droplet

On May 22, 2017, Apple released an update for the Master for iTunes Droplet that resolves these bugs. You can read more here, or download the new version here. Now that there’s an official version from Apple, I’ve removed the download link to my unofficial release.

I did this via Xcode 8.2.1 — from the Preferences -> Accounts -> View Details screen, I used the Create button to get the certificate. ↩