Apple adopted the digitally-signed xip format for Xcode downloads a few years ago. It’s basically a signed version of zip archives. Most commonly, you download a xip and double-click. Archive Utility will open the file, verify its signature, and expand its contents.
In its default settings, Archive Utility always expands files to the same folder you download to. With Xcode, this is a big pain as moving the app with its thousands and thousands of tiny subfiles and embedded executables takes forever. Alternatively, moving the xip file from one location on your system to another can be painfully slow.
Fortunately, Archive Utility does allow you to specify where to unpack. Launch the Application using spotlight (or /System/Library/CoreServices/Applications/Archive Utility.app) and open preferences.
Although there’s no “Ask” option for “Save expanded files”, you can select where you want items to be stored using “into” from the pop-up:
Once set, you have to unset it for general use, because the location persists between launches. This is, needless to say, a big pain when you use archives for non-Xcode purposes on a regular basis:
Fortunately, you can unxip more effectively by using the command-line
xip utility located in /usr/bin/xip without having to mess with Archive Utility or its preferences:
% xip Usage: xip [options] --sign <identity> <input-file> [ <input-file> ... ] <output-xip-file> Usage: xip --expand <input-file>
99.9% of everything you do with
xip is that last “Usage” example. Still, as
xip doesn’t offer a
--help option, if you want to know what those interesting
[options] are, you’ll need to read the man page (
man xip). I prefer to open man pages in Preview instead of the command line, using this little trick:
man -t xip | open -f -a /System/Applications/Preview.app
Notice two things here:
- First, the
-tflag tells man to use the Groff typesetter (no relation) to format the page to postscript. This presents as a PDF in Preview. (Specifically, it uses
/usr/bin/groff -Tps -mandoc -cif that kind of detail intrigues you.)
- Second, the path for Preview has changed in Catalina to /System/Applications. If you want to do this on Mojave or earlier, adjust the path accordingly.
(Isn’t that a neat way to view man pages?)
While the man page suggests you can sign your own xip archives and provide your own identities, don’t bother. This format is exclusive to Apple, starting from macOS Sierra. Only xip archives signed by Apple can be expanded in modern macOS releases. (See Tech note TN 2206 for details.)
--expand cannot be used with any other arguments, hop over to /Applications, and expand from there:
% cd /Applications/ % time xip --expand /Volumes/Kiku/xips/Xcode_11.2.1.xip
time command at the start of the line lets you know how long it took to unxip, which is deeply satisfying to those of pedantic bent like myself. For those playing along, it was
xip: expanded items from "/Volumes/Kiku/xips/Xcode_11.2.1.xip" 1109.625u 275.408s 10:58.85 210.2% 0+0k 0+0io 167pf+0w
Save this AppleScript as an App. Set the default opener for XIP files to it. Thank me later.
on open afile
set outFolder to choose folder
do shell script "cd " & quoted form of POSIX path of outFolder & ";xip –expand " & quoted form of POSIX path of afile
— Mark Lively (@MongoTheGeek) November 19, 2019