Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

What is the command line equivalent of the *compress* tool in *Finder*

I have an automatic build setup for our iPhone Apps. The one issue i face everytime is that the zip file that i create in the build using zip command is always rejected by iTunesConnect server as invalid binary. When i compress the .APP folder manually using Compress from the *Finder menu*, that archive is always accepted. The size of the zip files generated is slightly different.

Does anyone know what would be the command line equivalent of the Compress used by the Finder ? I want to automate this process so that someone does not have to do a manual compress before uploading it to iTunesConnect.

Thanks in advance,

-TRS

MacBook, Mac OS X (10.5.2)

Posted on Mar 11, 2009 6:16 AM

Reply
18 replies

Mar 11, 2009 9:41 PM in response to a Mac user

I am using the following zip command to compress the .app folder.

zip -r archive.zip MyApp.app

The size of the zip file created by this is about 1 KB smaller than the one created using the Compress utility and that one is accepted by iTunesConnect.

If i could just figure what arguments to use to create the file in the format that Apple will accept.

Thanks in advance for all your help.

-TRS

Mar 12, 2009 6:41 AM in response to a Mac user

a Mac user wrote:
That is odd, are you sure you are using the command line correctly then? Because zip-ing from the command line should be the exact same one as from the utility in OS X.


It's not the same, though. As someone else pointed out, the Finder uses a program called "Archive Utility.app", found in "/System/Library/CoreServices". A quick look at the binary shows that it uses the following Unix command line apps:

/usr/bin/macbinary
/usr/bin/file
/usr/bin/tar
/usr/bin/applesingle
/usr/bin/binhex
/usr/bin/ditto
/usr/bin/gunzip
/usr/bin/bunzip2
/usr/bin/uudecode
/usr/bin/atos

I would have to look into how iTunesConnect accepts files.


iPhone apps are signed binaries, so if one byte is different when they arrive at the app store, they won't be accepted. The command line zip leaves out some information and so the package appears to have been tampered with and they're rejected.

charlie

Mar 12, 2009 8:30 AM in response to Charles Minow

Charlie,

Thanks for your response.

The command line zip leaves out some information


I had not thought about that. Did not realize compression could be lossy.

I had assumed that the zip file could extract all that was put into it and hence assumed that iTunesConnect could only receive the zip file in a certain format. I had always assumed that it would first unzip the archive and then validate it.

I compress the AdHoc version the same way and it works just fine. I can unzip it and successfully install it on a provisioned device witout any issue.

I would really like to be able to generate the zip file in my build script instead of having someone manually compress the APP folder.

Thanks,

-TRS

Mar 12, 2009 9:53 AM in response to trshivku

trshivku wrote:
The command line zip leaves out some information


I had not thought about that. Did not realize compression could be lossy.


It's not that the zip compression itself is lossy, it's that the command line zip program doesn't include some files that compressing from the Finder does.

I'm not at a Leopard computer (and Tiger is different), or I'd do some experimenting. But someone else posted a suggestion to look at the "ditto" command, and I'd second that. If you don't have an answer by tonight, I'll see if I can get identical archives using the Finder and ditto.

You can look into your zip archives with "unzip -l" and see if you can spot the differences.

charlie

Mar 12, 2009 10:38 AM in response to James Walker1

I think this did it! Thank you so much.

This is the command i am using:

ditto -c -k --rsrc --extattr --keepParent myapp.app myapp.app.zip

This creates an archive which is exact same size as the one created by Compress

I used WinZip on a Windows PC to get the File->Properties and did a diff. All other information is identical except for a slight difference in the *extra field* values.

Unfortunately i don't have an app which i can submit today and test this out but will have something next week. Will test out and post my feedback. i have a feeling this is going to work 🙂.

Thanks for all your help.

-Shiva

Mar 12, 2009 10:41 AM in response to James Walker1

Hi James,

I am so stupid not to have seen this post and your comment that the files were the same size.

I tried it and it was the same size except for some difference in the *extra field* values. I will try using this in my next build that i submit to Apple and let everyone know if iTunesConnect is happy with the zip file.

Thanks so much.

-TRS

Mar 12, 2009 10:48 AM in response to trshivku

trshivku wrote:


Unfortunately i don't have an app which i can submit today and test this out but will have something next week.


You should be able to test it out right now by checking the MD5 checksum of your two archives. For sure if they're identical, the checksums would be the same:

md5 /path/to/zip/archive1.zip
md5 /path/to/zip/archive2.zip


charlie

Mar 12, 2009 1:53 PM in response to Charles Minow

Hi Charlie,

Thanks for the suggestion.

Even though the sizes are same the md5 hash is different. So i guess there is still something different for some reason.

I tried this with a folder with different set of files (not a regular APP folder) and again the sizes were same but the md5 hash was different.

So i guess the archives are different in some way. Maybe bits are arranged differently. The test would be to see if this difference is material to archive validator that iTunesConnect uses.

Thanks again for your prompt response.

-TRS

Mar 12, 2009 2:07 PM in response to trshivku

trshivku wrote:
So i guess the archives are different in some way. Maybe bits are arranged differently. The test would be to see if this difference is material to archive validator that iTunesConnect uses.


You're right, it could just be the bits arranged in a different way. Too bad, because if the hashes were identical, then you definitely would know they're the same...

cheers

charlie

What is the command line equivalent of the *compress* tool in *Finder*

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.