When codesigning a Mach-O file (OS X executables or libraries), the signature information will be stored in the file itself through some Mach-O extension. When codesiging a bundle (
_CodeSignature directory will be created. But what happens when you codesigning a plain text file? Signature information will be stored in extended attributes. Because of that, when packaging or copying files like those, you would expect the tools to preserve extended attributes. Not all of them do that by default.
tar on OS X preserves extended attributes by default, both archive and unarchive. But
zip doesn’t, a better replacement is
ditto can be used as a replacement for
cp as well, though
cp in OS X preserves extended attributes by default.
--extended-attributes will make sure it copies extended attributes.
When creating a dmg with
[hdiutil](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/hdiutil.1.html), keep in mind the
makehybrid command will lost extended attributes, so you will have to use alternative ways.