Swift executables in installer packages (.pkg) preinstall/postinstall

It seems that preinstall/postinstall scripts in installer packages (.pkg) are not limited to shell scripts, but can be any kind of executable (e.g. compiled Swift programs).

This sounds like an exciting possibility to re-use logic, constants, tests etc. from the app that is being installed, and at the same time benefit from Swift features like type safety for complex installer scripts.

Has anyone done this? What were your experiences?

Is it advisable, or is it likely to break on the next OS update?

Accepted Answer

The biggest concern with this approach is notarisation. Last I checked, the notary service built its ticket from the executables in the installer package content. However, it’s been a while so it’s be reasonable for you to test this, just to be sure.

To test this, notarise a package that uses such a tool and then fetch the notary log to see if the tool is included in the resulting ticket.

Another alternative is to install the tool you want to run and then just run it from your script. Obviously this is only helpful in the post-install case.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks! Looks like it's working fine and all the preinstall/postinstall binaries are indeed listed in the ticketContents when notarizing the package.

Swift executables in installer packages (.pkg) preinstall/postinstall
 
 
Q