productbuild(1) General Commands Manual productbuild(1)

productbuildBuild a product archive for the macOS Installer or the Mac App Store.

productbuild [--product requirements-plist] {--component component-path [install-path]} product-output-path

productbuild {--content content-path} product-output-path

productbuild [--product requirements-plist] {--root root-path install-path} product-output-path

productbuild [options] --distribution dist-path [--package-path search-path] product-output-path

productbuild --synthesize [--product requirements-plist] {--package pkg-path} distribution-output-path

A product archive is a flat file with a .pkg extension. productbuild creates a deployable product archive, which can be used with the macOS Installer, or submitted to the Mac App Store. It has 5 different modes, as shown in the SYNOPSIS above:

  1. If you have a self-contained bundle (e.g. an app) that always gets installed to the same location (e.g. /Applications), specify the bundle and install path using the --component option. You can specify additional requirements using a PRE-INSTALL REQUIREMENTS PROPERTY LIST. When you specify a bundle, productbuild automatically creates a component package, much like pkgbuild(1), and synthesizes a distribution file.
  2. Specify in-app content using the --content option.
  3. When you use xcodebuild(1) with the action, the result is a destination root, either under /tmp, or in whatever location you specify with the Xcode DSTROOT setting. Use the productbuild --root option to specify that destination root directory and its install path. You can specify additional requirements using a PRE-INSTALL REQUIREMENTS PROPERTY LIST. When you specify a root, productbuild automatically creates a component package, much like pkgbuild(1), and synthesizes a distribution file.
  4. If you have a distribution file, use the --distribution option to specify the path to it, and the --package-path option to specify the directory where the component packages are found (if they are not in the current working directory). All packages referenced by the distribution will be incorporated into the resulting product archive.
  5. This also synthesizes a distribution (also using an optional PRE-INSTALL REQUIREMENTS PROPERTY LIST), but writes out the resulting distribution instead of incorporating it into a product archive. This can serve as a starting point if a more sophisticated distribution is required.

use only the --component mode of productbuild. The other modes will create product archives that are compatible with the macOS Installer, but are not necessarily acceptable for the Mac App Store.

dist-path
Use the distribution file at dist-path to define the presentation, choices and packages to be installed by the product. Each of the package names referenced in the given distribution file must be found in a path specified with the --package-path flag.

If --distribution is omitted, a distribution will be synthesized to install all of the bundles given by --component flags, or all of the packages given by --package flags.

search-path
productbuild will search in search-path for component packages named in the distribution. You can use multiple --package-path flags if necessary. The current working directory is searched automatically.
rsrc-dir
productbuild will copy the resources from rsrc-dir into the resulting product archive. rsrc-dir can contain unlocalized resources (such as image files) and/or standard lproj directories (e.g. English.lproj) containing localized resources (such as strings files).
interface-type
If the distribution has multiple choices-outline elements, you can use --ui to select one for building the product archive: this controls which package references are used. The interface-type should match the value of the “ui” attribute on the desired choices-outline. The default is to use the choices-outline with no ui attribute.

If used without --distribution, the given interface-type will be used for the choices-outline of the synthesized distribution.

product-identifier
The given unique (non-localized) product-identifier will be associated with the product.
product-version
The given product-version string will be associated with the product.
component-path [install-path]
The bundle at component-path is added to the product archive (as its own component package) and to the synthesized distribution. If install-path is specified, it is used as the default install location for the bundle. (If you omit install-path, a location is inferred from the given component-path.)

Valid only if --distribution is not specified.

compression-mode
Allows control of compression used for storing any components added via the --component option. This option does not affect the compression used for plugins or scripts. Three compression-mode arguments are supported:
content-path
The contents of the directory at content-path are added to the product archive (as its own component package) and to the synthesized distribution.

Valid only if --distribution is not specified.

root-path install-path
The entire directory tree at root-path is added to the product archive (as its own component package) and to the synthesized distribution. This is typically used for a destination root created by xcodebuild(1).

Valid only if --distribution is not specified.

pkg-path [install-path]
The component package at pkg-path is added to the product archive and to the synthesized distribution. If install-path is specified, it is used as the default install location for the package, overriding any default location specified by the component package itself.

Valid only if --distribution is not specified.

If the package provided was created by the pkgbuild tool with the --large-payload option specified, then its large payload format will be preserved. The generated product's distribution will include a minimum system version requirement of macOS Monterey (12.0) or the minimum allowable system version(s) in the requirements property list, whichever is greater.

Write the synthesized distribution directly instead of incorporating it into a product archive.
requirements-plist
When synthesizing a distribution, use the requirements from requirements-plist. See PRE-INSTALL REQUIREMENTS PROPERTY LIST (this was formerly called the "product definition property list").
scripts-path
The contents of scripts-path is added to the product archive for use by system.run() commands in the distribution. This is valid only for product archives targeted to the macOS Installer application.
plugins-path
The contents of plugins-path is added to the product archive for use by the macOS Installer application's plugin mechanism. It will normally contain a InstallerSections.plist file, and one or more plugin bundles.
By default, packages that are nested inside of products have a per‐file size limit associated with them. This method instructs productbuild to construct a product where the included payload format supports large files. A large file is defined as any file that is 8 GiB or larger.

Note: Opting into --large-payload enforces a distribution requirement that mandates macOS Monterey (12.0) or later.

identity-name
Adds a digital signature to the resulting package. See SIGNED PRODUCT ARCHIVES
keychain-path
Specify a specific keychain to search for the signing identity. See SIGNED PRODUCT ARCHIVES
certificate-name
Specify an intermediate certificate to be embedded in the package. See SIGNED PRODUCT ARCHIVES
Include a trusted timestamp with the signature. See SIGNED PRODUCT ARCHIVES
Disable trusted timestamp, regardless of identity. See SIGNED PRODUCT ARCHIVES
Inhibits status messages on stdout. Any error messages are still sent to stderr.
product-output-path
The path to which the product archive will be written.
distribution-output-path
When --synthesize is used, the path to which the synthesized distribution will be written.

When you use productbuild to synthesize a distribution (e.g. with the --component option), you can specify pre-install requirements in a separate property list file, specified with the --product option. (When you use Xcode to create a package for the Mac App Store, you can specify this file using the "Pre-install Requirements Property List" build setting.)

At the top level, this property list is a dictionary, with the following keys:

Minimum allowable OS versions (array of strings)
Supported architectures (array of strings)
Minimum required RAM in gigabytes (real)
Specific bundles that must exist on the system (array of dictionaries)
Are all of the bundles specified required? (Boolean)
Required OpenGL capabilities (string)
Required OpenCL capabilities (string)
Required Metal capabilities (string)
Requires that OpenGL, OpenCL, and Metal requirements be met by a single device. (Boolean)
Additional required hardware properties (string)
Should installation be allowed in user home directory? (Boolean)

When creating a product archive, you can optionally add a digital signature to the archive. You will need to have a certificate and corresponding private key -- together called an “identity” -- in one of your accessible keychains. To add a signature, specify the name of the identity using the --sign option. The identity's name is the same as the “Common Name” of the certificate.

If you want to search for the identity in a specific keychain, specify the path to the keychain file using the --keychain option. Otherwise, the default keychain search path is used.

productbuild will embed the signing certificate in the product archive, as well as any intermediate certificates that are found in the keychain. If you need to embed additional certificates to form a chain of trust between the signing certificate and a trusted root certificate on the system, use the --cert option to give the Common Name of the intermediate certificate. Multiple --cert options may be used to embed multiple intermediate certificates.

The signature can optionally include a trusted timestamp. This is enabled by default when signing with a Developer ID identity, but it can be enabled explicitly using the --timestamp option. A timestamp server must be contacted to embed a trusted timestamp. If you aren't connected to the Internet, you can use --timestamp=none to disable timestamps, even for a Developer ID identity.

Note that component packages do need to be signed (e.g. with pkgbuild(1)) before adding them to a signed product archive. The signature on the product archive protects the entire product, including the added packages.

If you want to postpone signing the product archive until it has been tested and is ready to deploy, you can use productsign(1) when you are ready to add the signature.

Build the archive Product.pkg to install Sample.app under /Applications, synthesizing a distribution. This is typical for building a Mac App Store archive.

Build the archive Product.pkg to install Sample.app under /Applications, synthesizing a distribution with the requirements from def.plist. This is typical for building a Mac App Store archive with pre-install requirements.

Build the archive Product.pkg using Product.dist, searching for packages referenced by that distribution in /tmp/Packages (as well as in CWD).

Build the archive Product.pkg using Product.dist, incorporating the resources found under the Resources directory.

Build the archive Product.pkg using Product.dist, and sign the resulting archive using the identity sample-identity. You will be prompted to allow productbuild to access the keychain item, unless Always Allow was chosen previously.

Build the archive Product.pkg with the component packages /tmp/a.pkg and /tmp/b.pkg, synthesizing a distribution.

pkgbuild(1), productsign(1), xcodebuild(1)

January 19, 2021 macOS