Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a zip file in the same format as the Finder's "Compress" menu item?

On Mac OS X, you can create a zip archive from the Finder by selecting some files and selecting "Compress" from the contextual menu or the File menu. Unfortunately, the resulting file is not identical to the archive created by the zip command (with the default options).

This distinction matters to at least one service operated by Apple, which fails to accept archives created with the zip command. Having to create archives manually is preventing me from fully automating my release build process.

How can I create a zip archive in the correct format within a shell script?

EDIT: Since writing this question long ago, I've figured out that the key difference between ditto and zip is how they handle symbolic links: because the code signature inside an app bundle contains a symlink, it needs to be preserved as a link and not stored as a regular file. ditto does this by default, but zip does not (option -y is required).

like image 280
benzado Avatar asked Sep 20 '08 11:09

benzado


People also ask

How do I compress and create a zip file?

Right-click on the file or folder.Select “Compressed (zipped) folder”. To place multiple files into a zip folder, select all of the files while hitting the Ctrl button. Then, right-click on one of the files, move your cursor over the “Send to” option and select “Compressed (zipped) folder”.

How do I change the compression on a zip file?

Press and hold (or right-click) the file or folder, select (or point to) Send to, and then select Compressed (zipped) folder. A new zipped folder with the same name is created in the same location. To rename it, press and hold (or right-click) the folder, select Rename, and then type the new name.

How do I make a compressed zip folder?

In your computer's files, choose the folder you'd like to zip/compress. Right-click the folder, choose Send to, and then click Compressed (zipped) folder. A new zipped folder will appear in the same location as your original folder. This Zip File can now be used for your HTML drop.

Is compress on Mac the same as zip?

The compressed file will have the same name as the original folder. The only difference is that it will have a . zip extension at the end. The zip folder will also be in the same folder as the original folder.


2 Answers

I have a ruby script that makes iPhone App Store builds for me, but the zips it was generating wouldn't get accepted by iTunes Connect. They were accepted if I used Finder's "Compress" function.

millenomi's answer came close for me, but this command is what ended up working. iTunes Connect accepted my build, and the app got approved and can be downloaded no problem, so it's tested.

ditto -c -k --sequesterRsrc --keepParent AppName.app AppName.zip 
like image 61
Jared Egan Avatar answered Sep 30 '22 21:09

Jared Egan


Use the ditto command-line tool as follows:

ditto -ck --rsrc --sequesterRsrc folder file.zip 

See the ditto man page for more.

like image 37
millenomi Avatar answered Sep 30 '22 20:09

millenomi