Xcode copy release build signed target

I am trying to find a way to copy the signed target from Xcode Release build to a local directory as part of the build process.

If I use a "run script" build phase it executes BEFORE the target is signed, so will not accomplish that goal.

If I use a "copy file" build phase, it does have an option for signing and so that does "work"; however it always copies the DEBUG version.

Is there a way to copy the Release build target?

EG can a run script execute the code sign program, and, if so what would the command line parameters be? OR

is there a way to modify the copy file phase to copy the Release build rather than the Debug build? OR

??

Answered by DTS Engineer in 831035022

Thank you for explaining. We discussed your case here and we recommend doing an archive build and then copying the app out of the archive. We expect this will give you the best results using code paths that are currently supported.

You can copy the app out of the .xarchive by changing the file name ending from .xarchive to .zip. Then you can open the .zip file and copy the app into the Applications folder.

Note ~ Searching on the web I found some folks talking about duplicating the run Scheme and changing the "Build Configuration" to "Release" and using the result from that. That may work in some cases, but it may not produce correct results in others. This is not a supported code path. We do not recommend using this duplicate Scheme approach.

Hello. Thanks for asking about this. Generally speaking, one should be doing an archive build and then archive export to produce a distribution signed release build. If that route isn't enough for your purposes then please provide some additional information about what you're trying to do and your reasons for wanting to have a separate copy of a distribution signed release build. We'd like to know more so we can consider what recommendations we can provide for you.

Hi and thanks for your response. I am just a hobbyist developer who writes MacOS apps for personal use on my machines at home; as such I just sign them to run locally and do not really have a need to be involved in archiving and distribution build processes. Currently I will make changes, etc, create a "debug" build for testing; afterwards will create a "release" build that will be used for execution; after creating this "release" build I open the build folder while still in Xcode and manually copy the app to my application directory. My goal (as stated in the question I raised) is to somehow have that copying incorporated into the build process for the "release" build. It is not a big deal, just seemed like there should be a way to do it.

Thank you for explaining. We discussed your case here and we recommend doing an archive build and then copying the app out of the archive. We expect this will give you the best results using code paths that are currently supported.

You can copy the app out of the .xarchive by changing the file name ending from .xarchive to .zip. Then you can open the .zip file and copy the app into the Applications folder.

Note ~ Searching on the web I found some folks talking about duplicating the run Scheme and changing the "Build Configuration" to "Release" and using the result from that. That may work in some cases, but it may not produce correct results in others. This is not a supported code path. We do not recommend using this duplicate Scheme approach.

ok; thanks for the response; not sure what would be the difference between following your recommendation and just manually copying from build folder from within Xcode (as i am currently doing) but will consider it.

In the meantime I did come up with a semi-automated approach: (1) add a run script which tests for release build and emits a "cp ..." command to an external file (this works because that script runs with full Xcode build environment so can publish the build folder path) (2) manually execute that external file when I want to copy the build to applications folder

Xcode copy release build signed target
 
 
Q