I am trying to create a .pkg installer for a CLI on macOS (Monterey). I have come across pkgbuild
and productbuild
.
They are already installed on my mac.
Where can i read more about what these CLIs do? (not only how to use).
What is the difference between the two?
I came across them from this stack overflow thread: Making macOS Installer Packages which are Developer ID ready
pkgbuild
builds a macOS Installer "component package". A component package contains a payload to be installed by the macOS Installer. Throughout the man pages, component packages are also referred to as "packages". Although a component package can be installed on its own, it is typically incorporated into a "product archive", along with a distribution file and localized resources, usingproductbuild
.productbuild
builds a "product archive" for the macOS Installer or the Mac App Store. A product archive is also a file to be used by the macOS Installer, but it can contain multiple component packages to be installed. And by usingproductbuild
to create a product archive, you can add elements to customize the installation process for users (such as your own text, license agreement, localized resources, logo etc.). You will see product archives also referred to as "distribution packages" 1 2 and "installer packages" 3. If you want to upload your bundle/app to the Mac App Store, then you need to create a product archive for it withproductbuild
rather than only usingpkgbuild
.Confusingly the output files (component packages and product archives) of the two commands both have the same extension (
.pkg
). But you can find out more about a.pkg
by looking at the contents, which you can see by right clicking it and selecting Show Package Contents or by runningpkgutil --expand my-package.pkg path/to/expand
. 4Hopefully some of those links provide you with some more reading material about what the commands do. This blogpost details more about using the two commands, and this is a good blog post outlining how the commands can be used to create a custom
.pkg
installer for a macOS application.