diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0047e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# Xcode +build/* +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside + +#OSX Generated Stuff +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db + +# Custom +DerivedData/* +*/DerivedData/* +coverage.xml +test-report.xml +*/test-reports/* +*.xarchive + +# ITMS +itms/* +environment-local.sh diff --git a/README.md b/README.md index 9bc8241..922d5a1 100644 --- a/README.md +++ b/README.md @@ -6,47 +6,57 @@ This script helps prepare localized screenshots for delivery to iTunes Connect v *** #### Step 1 -Open your app in iTunes Connect and create a new version. Ensure your app is listed in the "Prepare for Upload" status. Download your app's metadata package from Apple. +Open your app in iTunes Connect and create a new version. Ensure your app is listed in the "Prepare for Submission" status. Download your app's metadata package from Apple using the download script. - ITMSUSER=YourItunesUsername - ITMSPASS=YourItunesPassword - ITMSSKU=YourAppSKU - PATH="$PATH:/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/MacOS/itms/bin/" - iTMSTransporter -m lookupMetadata -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -destination ~/Desktop + > `download-metadata.sh` -This will save the .itmsp file to your desktop. +This will save the .itmsp archive to the directory you specify, defaulting to `./itms/itmsp`. You'll also find a new screenshots directory under there too. #### Step 2 -Take screenshots and save them to `~/Desktop/screenshots` with the format like +Take screenshots and save them to this new directory `./itms/screenshots-raw` with the format like - > `cmn-Hans___ios4in___portrait___screen1.png` + > `en-GB___iOS-4-in___screen1.png` -This is comprised of sections delimited by `___`: +This is comprised of case sensitive sections delimited by three underscores `___`: - - Device name: correct names are `Mac`, `iOS-3.5-in`, `iOS-4-in` or `iOS-iPad` - - Locale: like `es-ES`, `fr-FR`, `ja-JP`, `en-US`, **HELP: NEED HELP FULLY DOCUMENTING LOCALE NAMES IN ITMS** + - Device: Correct names are (currently) `Mac`, `iOS-3.5-in`, `iOS-4-in`, `iOS-4.7-in`, `iOS-5.5-in` or `iOS-iPad` + - Locale: like `es-ES`, `fr-FR`, `ja-JP`, `en-US`, `en-CA`, `en-GB`, `en-AU`, `cmn-Hans`, `cmn-Hant` **HELP: NEED HELP FULLY DOCUMENTING LOCALE NAMES IN ITMS** + - Orientation: optional (`portrait`) + - Screen: screenN where N is the ordering for it when uploaded `(1,2,3,4,5)` + - Extension: always use .png Optional: write a UI script and automate generation of screenshots for all devices and localizations using https://github.com/jonathanpenn/ui-screen-shooter Note: if your screenshots are in the format `Locale/Devicename___other.png`, fix this with: `for a in */*; do d=$(dirname $a); f=$(basename $a); mv $a ${d}___${f}; done; rmdir */` +If you are unsure of any country codes, check the `metadata.xml` file that is downloaded in step 1 + +The files can be in subdirectories as they will be flatted in the next step + #### Step 3 -Run `php screenshots.php` – this will add the XML chunks you need and make a fresh copy of your `metadata.xml` in the screenshots folder. +Prepare the screenshots you have generated by running the verify script. + +> `prepare-screenshots.sh` + +This will make a copy of your screenshots, flattened from the `screenshots-raw` version, in the .itmsp package, ready for upload. #### Step 4 -Copy the contents of "screenshots" on your desktop into the itmsp file on your desktop (right-click -> show package contents to access the latter). Or use the following command: +Generate a new metadata file for the new screenshots. - cp ~/Desktop/screenshots/* ~/Desktop/*.itmsp +> `php screenshots.php` + +This will add the XML chunks you need and write an updated copy of your `metadata.xml` in the `$ITMSFOLDERNAME` folder. +A copy of what was actually generated will also be written to `xml_chunks_DEBUG.txt`. This DEBUG file can be discarded if not needed. #### Step 5 -Verify your upload: +Verify the content you have generated can be uploaded by running the verify script. - iTMSTransporter -m verify -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -f ~/Desktop/*.itmsp +> `verify-metadata.sh` Error "software_screenshots cannot be edited in the current state" happens if your app is currently being reviewed. #### Step 6 -If things went well, execute your upload: +All being well, you can perform the actual upload - iTMSTransporter -m upload -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -f ~/Desktop/*.itmsp +> `upload-metadata.sh` ----------------- @@ -56,6 +66,13 @@ You can modify Xcode schemes to automatically launch your app in a particular lo On top of that, I wanted localized users for my screenshots, so I pass an Environment Variable of "USER_ID", then grab that in my code & setup the user programmatically. You can get Environment Variables via: [[NSProcessInfo processInfo] environment] +You can speed things up by having a file called `environment-local.sh` in which you define the details that you are otherwise prompted for: + +ITMSUSER='myitmsusername' +ITMSPASS='myitmspassword' +ITMSSKU=com.myapp.sku + +All of the shell scripts will use this instead, if available. ## Heads Up diff --git a/download-metadata.sh b/download-metadata.sh new file mode 100755 index 0000000..b3ec10a --- /dev/null +++ b/download-metadata.sh @@ -0,0 +1,8 @@ +. environment.sh + +echo "Downloading..." + +iTMSTransporter -m lookupMetadata -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -destination $ITMSFOLDERNAME + +echo "itmsp package is now at $ITMSFOLDERNAME" +echo "Now put your screenshots into $ITMSSCREENSHOTSFOLDERRAWNAME and run prepare-screenshots.sh" diff --git a/environment.sh b/environment.sh new file mode 100755 index 0000000..2c59bbe --- /dev/null +++ b/environment.sh @@ -0,0 +1,42 @@ +if [ -f "environment-local.sh" ]; +then + echo "Using local environment variables in environment-local" + . environment-local.sh +fi + +ITMSFOLDERNAME=./itms +ITMSSCREENSHOTSFOLDERRAWNAME="$ITMSFOLDERNAME/screenshots-raw" + +PATH="$PATH:/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/itms/bin/" + +if [ -z "$ITMSUSER" ]; +then + read -p "Username:" ITMSUSER +fi + +if [ -z "$ITMSPASS" ]; +then + read -s -p "Password:" ITMSPASS + echo "" +fi + +if [ -z "$ITMSSKU" ]; +then + read -p "SKU:" ITMSSKU +fi + +if [ -d "$ITMSFOLDERNAME" ]; +then + echo "Directory $ITMSFOLDERNAME already exists. This might be expected but it might mean old assets lying around" +else + echo "Making directory $ITMSFOLDERNAME for the itmsp package" + mkdir $ITMSFOLDERNAME +fi + +if [ -d "$ITMSSCREENSHOTSFOLDERRAWNAME" ]; +then + echo "Directory $ITMSSCREENSHOTSFOLDERRAWNAME already exists. This might be expected but it might mean old screenshots lying around" +else + echo "Making directory $ITMSSCREENSHOTSFOLDERRAWNAME for the screenshots" + mkdir $ITMSSCREENSHOTSFOLDERRAWNAME +fi diff --git a/prepare-screenshots.sh b/prepare-screenshots.sh new file mode 100755 index 0000000..4e25d51 --- /dev/null +++ b/prepare-screenshots.sh @@ -0,0 +1,9 @@ +. environment.sh + +echo "Ensuring screenshots are flattened and in place in the package..." + +for i in `find $ITMSSCREENSHOTSFOLDERRAWNAME -name \*.png -print`; do + cp -v -f $i "$ITMSFOLDERNAME/$ITMSSKU.itmsp/" +done + +echo "Now run php screenshots.php to splice in the new screenshots" diff --git a/screenshots.php b/screenshots.php index 330a850..51f1fa7 100755 --- a/screenshots.php +++ b/screenshots.php @@ -2,13 +2,17 @@ asXML("$screen_shots_dir/metadata.xml"); - echo "Saved updated metadata.xml file to $screen_shots_dir/metadata.xml\n"; + $itmsp_parsed->asXML("$itmsps[0]"); + echo "Saved updated metadata.xml file to $itmsps[0]\n"; + echo "Now you can run verify-metadata.sh to check it all looks fine\n"; } function xmlChunk($display_target, $position, $file_path, $file_name) @@ -90,17 +95,3 @@ function xmlChunk($display_target, $position, $file_path, $file_name) END; } - - -function translateDevice($device) -{ - if ($device == 'iphone4') { - return 'iOS-3.5-in'; - } elseif ($device == 'iphone5') { - return 'iOS-4-in'; - } elseif ($device == 'ipad') { - return 'iOS-iPad'; - } else { - print "\n\n\n******\n\nWTF $device\n\n\n"; - } -} diff --git a/upload-metadata.sh b/upload-metadata.sh new file mode 100755 index 0000000..3899e15 --- /dev/null +++ b/upload-metadata.sh @@ -0,0 +1,7 @@ +. environment.sh + +echo "Uploading..." + +iTMSTransporter -m upload -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -f "$ITMSFOLDERNAME/$ITMSSKU.itmsp" + +echo "Done!" diff --git a/verify-metadata.sh b/verify-metadata.sh new file mode 100755 index 0000000..b8899f2 --- /dev/null +++ b/verify-metadata.sh @@ -0,0 +1,5 @@ +. environment.sh + +echo "Verifying..." + +iTMSTransporter -m verify -u $ITMSUSER -p $ITMSPASS -vendor_id $ITMSSKU -f "$ITMSFOLDERNAME/$ITMSSKU.itmsp"