Search code examples
xcodemacosbuildsignpost-build-event

Run a post-signing script in Xcode 12


Xcode 12 performs a binary signing after all steps of the build have ended, including any custom post-build steps.

However I need to run a script to be performed after signing (e.g. for copying the signed binary elsewhere - but also for other things).

After having read a few StackOverflow questions and replies, I tried the following (separately):

  1. Create an aggregate target with two subtargets that (1) performs the build & sign, (2) runs the final post build.
  2. Use the scheme's build post-action to run the final post build.

Both don't work out of the box, and the problems are:

  1. Aggregate target solution (if it worked): means that I have to create and maintain such a target for all of my many projects.
  2. Post-action: does not appear in the build transcript, which makes it very cumbersome to detect errors. Moreover, a failure in the post-action does not fail the build - which is an absolute no-no.
  3. In both cases the custom user definitions are not passed into any of the steps, which renders my script useless, as it relies heavily on those definitions.

Is there any proper solution to the seemingly trivial request for a post-sign action?


Solution

  • The workaround I found was this: As a post-build step, copy the binary elsewhere, perform any required operations on it, and then manually sign it.

    Xcode will sign the original binary which is of no use to me.