{"id":332,"date":"2009-10-22T12:41:02","date_gmt":"2009-10-22T03:41:02","guid":{"rendered":"http:\/\/www.codedojo.com\/?p=332"},"modified":"2010-01-06T10:07:16","modified_gmt":"2010-01-06T01:07:16","slug":"the-secrets-of-compress-vs-winzip-when-packing-your-iphone-app","status":"publish","type":"post","link":"https:\/\/www.codedojo.com\/?p=332","title":{"rendered":"The secrets of Compress vs Winzip when packing your iPhone App"},"content":{"rendered":"<h2><strong>Beta Testing Disaster: &#8220;It Crashed&#8221;<\/strong><\/h2>\n<p>I smiled as the <strong>AdHoc<\/strong> version of my new iPhone game zipped through the intertubes, neatly delivering itself to each beta tester to enjoy with his cheese and wine.\u00a0 What could go wrong, <strong>my code is perfect as always<\/strong>.\u00a0 (Yeah&#8230;)<\/p>\n<p>My <strong>smirk turned to horror <\/strong>as the replies came in &#8211; two of my ten testers reported that the<strong> game instantly crashed<\/strong> after the splash screen.<\/p>\n<h2><strong>Using logic, reason, and Jetro to figure it out<\/strong><\/h2>\n<p>Would this happen in real distribution? Can I really release a game that <strong>crashes on 20% of devices<\/strong>?\u00a0 Not on my watch, not at RTsoft! (19% is our cut-off point)<\/p>\n<p>They both happened to be 3GS devices.\u00a0 A divide by zero that only happens with the faster processor?\u00a0 Why didn&#8217;t the other two 3GS testers crash?\u00a0 Related to being jailbroken?\u00a0 iPhone OS version?<\/p>\n<p><strong>Nope, none of the above.<\/strong><\/p>\n<ul>\n<li>The first big clue was when we noticed that <strong>no crash log was created<\/strong> &#8211; this made it likely that the <strong>app wasn&#8217;t even starting<\/strong>.\u00a0 (The splash screen is actually shown by the OS while the real game loads)<\/li>\n<li>The second clue was when we noticed that only those using <strong>iTunes on the mac<\/strong> had the problem.\u00a0 Forgot to ask about OS when signing up testers&#8230;<\/li>\n<li>I would have to say the biggest clue was when <a href=\"http:\/\/jet.ro\/\">Jetro<\/a> figured it out and <strong>told me what the problem was<\/strong>.\u00a0 Yeah, that helped.<\/li>\n<\/ul>\n<h2><strong>It&#8217;s the packaging, dummy<\/strong><\/h2>\n<p>I&#8217;m a windows guy.\u00a0 I test, debug,\u00a0 package and ftp my stuff in Windows.\u00a0 I use .bat file scripts for <strong>frakin&#8217; everything<\/strong>.<\/p>\n<p>This is <strong>A Bad Thing<\/strong> when packing iPhone stuff.<\/p>\n<p>Actually I made <strong>two mistakes<\/strong>.\u00a0 And yeah, they are both explicitly warned against in the iPhone developer documentation so I really have no excuse here.<\/p>\n<h2><strong>Mistake 1: Letting XCode use a networked Windows drive to build on<br \/>\n<\/strong><\/h2>\n<p>I was using a windows network drive for my build directory.\u00a0 It has the unfortunate side effect of losing some permission data and just setting everything to +x (executable).<\/p>\n<p><a href=\"http:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/xcode_build.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-333\" title=\"xcode_build\" src=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/xcode_build-282x300.jpg\" alt=\"xcode_build\" width=\"282\" height=\"300\" srcset=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/xcode_build-282x300.jpg 282w, https:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/xcode_build.jpg 963w\" sizes=\"auto, (max-width: 282px) 100vw, 282px\" \/><\/a><\/p>\n<p>Interesting fact though, despite the strange attributes, you CAN use OS X&#8217;s <strong>Compress<\/strong> and create a working AdHoc and even final distribution build from a build on a networked Windows drive.\u00a0 I know, because Apple accepted <a href=\"http:\/\/www.rtsoft.com\/pages\/dscroll_iphone.php\">Dungeon Scroll<\/a>&#8230;\u00a0 However, looking at this, I won&#8217;t do that again.<\/p>\n<h2><strong>Mistake 2: Zipping from Windows using 7zip or Winzip<br \/>\n<\/strong><\/h2>\n<p>The rules of iPhone zip packing:<\/p>\n<ul>\n<li>Zipping from Windows using Winzip or 7zip <strong>does NOT store<\/strong> special os x\/linux file attributes\/permissions, and that is Not A Good Thing.<\/li>\n<li>Using &#8220;Compress&#8221; on the Mac does it right.\u00a0 I mean hey, all those weird junk files OS X adds had to be good for something, right?<\/li>\n<\/ul>\n<p>When unzipped and installed through iTunes on OS X, everything installs ok, but when you run the game on\u00a0 the device it notices the game binary doesn&#8217;t have the <strong>+x<\/strong> execution attribute set and fails.\u00a0 <strong><\/strong><\/p>\n<p><strong>Note:<\/strong> In a bind, you can fix this by using chmod on it manually before you install.\u00a0 Could save you if you are a beta tester who has to deal with this problem and can&#8217;t get hold of the developer.<\/p>\n<h2><strong>Zipping on the mac from shell script<\/strong><\/h2>\n<p>So the next question of course is &#8220;Fine, I&#8217;ll use the damn mac, but how can I automate this?&#8221;<\/p>\n<p><a href=\"http:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/command_icon.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-363\" title=\"command_icon\" src=\"https:\/\/www.codedojo.com\/wp-content\/uploads\/2009\/10\/command_icon.jpg\" alt=\"command_icon\" width=\"218\" height=\"145\" \/><\/a><\/p>\n<p>Pretty easy.\u00a0 Here is how to make an icon that will make the zip and add your adhoc .mobileprovision. (This would only be for sending to testers)<\/p>\n<ul>\n<li> Create a text file and name it <strong>build.command<\/strong><\/li>\n<li>Insert the script pasted below, customized it for what you need<\/li>\n<li>Drop to the command prompt and do:<strong> chmod +x build.command<\/strong><\/li>\n<li>From Finder, find the file, right click and choose Make Alias<\/li>\n<li>Drag the alias to your desktop<\/li>\n<\/ul>\n<p>Now you can click the icon and have your zip made and copied somewhere for you!<\/p>\n<p>I&#8217;ll leave it to you to figure out how to also have it do the xcode building and ftp it somewhere.<\/p>\n<p>Here is the simple script to zip it up:\u00a0 (It uses ditto for the zipping.. which I should really verify is going to work with everything, but hey, Trust Me)<br \/>\n<code>#!\/bin\/bash<br \/>\necho Zip .app with the mobileprovision for beta testers<\/p>\n<p>#App name is the MyGame.app without the app part, that will be added<br \/>\nAPPNAME=RT4Player<\/p>\n<p>OUTPUTZIPNAME=${APPNAME}AdHoc.zip<\/p>\n<p>#buildir is the root build directory as set in xcode<br \/>\nBUILDDIR=~\/build<\/p>\n<p>#mobile provision to include for the beta testers to add using itunes<br \/>\nMOBILEPROVISIONFILE=\/Volumes\/projects\/iphone\/AppleStuff\/RTAdHoc.mobileprovision<\/p>\n<p>#make a temp dir to put our files in first, as ditto can't seem to add files to an existing zip<br \/>\nmkdir $BUILDDIR\/temp<\/p>\n<p>#copy the files want to zip there<br \/>\nditto $BUILDDIR\/AddHoc-iphoneos\/$APPNAME.app $BUILDDIR\/temp\/${APPNAME}.app<br \/>\ncp $MOBILEPROVISIONFILE $BUILDDIR\/temp<\/p>\n<p>#actually make the zip<br \/>\nditto -c -k $BUILDDIR\/temp $BUILDDIR\/${OUTPUTZIPNAME}<br \/>\nrm -rf $BUILDDIR\/temp\/<\/p>\n<p>#copy it over to our windows drive, as that's where my .bat files will rename it and ftp it<br \/>\ncp $BUILDDIR\/${OUTPUTZIPNAME} \/Volumes\/projects\/iphone\/$APPNAME<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Beta Testing Disaster: &#8220;It Crashed&#8221; I smiled as the AdHoc version of my new iPhone game zipped through the intertubes, neatly delivering itself to each beta tester to enjoy with his cheese and wine.\u00a0 What could go wrong, my code is perfect as always.\u00a0 (Yeah&#8230;) My smirk turned to horror as the replies came in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-development","category-tech-tips"],"_links":{"self":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332"}],"version-history":[{"count":35,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":514,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=\/wp\/v2\/posts\/332\/revisions\/514"}],"wp:attachment":[{"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codedojo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}