Compress a folder via a command line while persisting its icon I have a folder with a custom icon (via NSWorkspace's setIcon:forFile:options). 

I would like to zip the folder so the custom icon is preserved after unzipping.

Currently, I call

zip -r9 Folder.zip Folder


When I uncompress it via Finder, the uncompressed folder does not have any custom icon and the folder contains an item named Icon?.

How to fix it / how to compress the folder properly?
The command-line zip command doesn't seem to be able to hand certain aspects of macOS, including icons, but the more traditional unix tar utility can. You can make use of this by replacing your command with the following (this will also compress the folder using gzip):

tar -czf Folder.tar.gz Folder