Previous 1 2 Next 18 Replies Latest reply: Mar 19, 2009 2:11 PM by trshivku
trshivku Level 1 Level 1
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)
Reply by James Walker1 on Mar 11, 2009 8:14 PM Helpful
I think ditto, with some combination of options, will do it. Maybe

ditto -c -k --rsrc --extattr

I'm not sure about the --keepParent and --sequesterRsrc options.
Reply by James Walker1 on Mar 11, 2009 11:53 PM Helpful
I think what you want is

ditto -c -k --rsrc --keepParent path-to-app path-to-zip

I tried it on an app, and also compressed the app with the Finder, and the two archives were exactly the same size down to the byte.

All replies

  • a Mac user Level 3 Level 3
    you could use the unix command zip or gunzip or tar, depends on how you want to use it I guess.
  • RayNewbie Level 5 Level 5
    I don't think there are any options to /usr/bin/zip that will duplicate what you get from the Finder, which is using /system/Library/CoreServices/Archive Utility.app. I'm guessing you could do something with AppleScript, but can't find any scripting info specific to that utility.
  • a Mac user Level 3 Level 3
    actually there is, I have used it in my applications before. zip and unzip.
  • James Walker1 Level 1 Level 1
    I think ditto, with some combination of options, will do it. Maybe

    ditto -c -k --rsrc --extattr

    I'm not sure about the --keepParent and --sequesterRsrc options.
  • trshivku Level 1 Level 1
    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
  • James Walker1 Level 1 Level 1
    I think what you want is

    ditto -c -k --rsrc --keepParent path-to-app path-to-zip

    I tried it on an app, and also compressed the app with the Finder, and the two archives were exactly the same size down to the byte.
  • a Mac user Level 3 Level 3
    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. Possibly a permissions problem? I would have to look into how iTunesConnect accepts files.
  • Charles Minow Level 6 Level 6
    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
  • trshivku Level 1 Level 1
    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
  • Charles Minow Level 6 Level 6
    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
  • trshivku Level 1 Level 1
    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
  • trshivku Level 1 Level 1
    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
  • Charles Minow Level 6 Level 6
    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
  • trshivku Level 1 Level 1
    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
Previous 1 2 Next