Hello!
We have code that extracts macOS Installer package (.pkg, .mpkg) signature information using APIs defined in <xar/xar.h>
The code opens the package using ‘xar_open’ API like this.
func open(file: String) throws(XarError) { xarfile = xar_open(file, READ) if xarfile == nil { throw .fileOpenError } }
This code produces a clang warning in our CI build system when built for macOS 12 and up.
'xar_open' was deprecated in macOS 12.0: xar is a deprecated file format and should not be used.
Question #1:
- What is the appropriate / more preferred way to extract signature information from an Installer package given that xar related APIs are deprecated?
We use xar APIs to validate the package signature prior to installation to prevent packagers not signed by our team ID from being installed.
Question #2:
- “xar is a deprecated file format and should not be used.”. Does this phrase refer to the file format that should be avoided or the API that extract signature information?
We distribute our product using Developer ID method that using pkg/mpkg formats which I believe internally follow the same structure as xar files. I hope this message does not mean we should rethink the distribution method for our products.
Thank you.
Filed FB FB17148233 as well.
The xar file format definitely originated with Apple. It came from an era when everything had an X in it (-:
The format was originally pitched as being a general-purposes archive format, but that never came to pass. Never bet against the venerable tar file format (-:
That explains why the <xar.h>
API was deprecated. Apple recommends against using it for new applications [1]. However, the xar format is still used in a number of existing applications, most notably the flat installer package format.
IMPORTANT The installer package format is not deprecated. That deprecation notice is about the API specifically.
You have a choice of how to proceed here:
-
Suppress the deprecation warning and stay on your current path.
-
Stick with installer packages but use
pkgutil
to check their signature. -
Move away from the installer package format entirely.
It’s hard to offer specific advice here. My general inclination is to move off deprecated APIs as soon as possible, but in this case the decision is tangle up with your distribution file format, and it’s hard to predict how that will pan out.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] For new applications we recommend the Apple Archive framework, which comes with its own archive format. I talk about that more in Unpacking Apple Archives.