Skip to content

Instantly share code, notes, and snippets.

@bimusiek
Created November 28, 2014 14:49
Show Gist options
  • Save bimusiek/efc9f1d54436b228d04f to your computer and use it in GitHub Desktop.
Save bimusiek/efc9f1d54436b228d04f to your computer and use it in GitHub Desktop.
Upload app to iTunesConnect
#!/bin/bash
set -ex
# Based on other gist, fixed issue with typo and added argument for APP_ID.
# Your username and password should be set as environment variable $ITUNESCONNECT_LOGIN and $ITUNESCONNECT_PASSWORD
# This scripts allows you to upload a binary to the iTunes Connect Store and do it for a specific app_id
# Because when you have multiple apps in status for download, xcodebuild upload will complain that multiple apps are in wait status
# Requires application loader to be installed
# See https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html
# Itunes Connect username & password
if [ $# -lt 2 ]; then
echo 'Usage: upload_itunes_connect.sh APP_ID IPK_FILE'
exit 1
fi
APP_ID=$1
IPA_FILE=$2
IPA_FILENAME=$(basename $IPA_FILE)
MD5=$(md5 -q $IPA_FILE)
BYTESIZE=$(stat -f "%z" $IPA_FILE)
TRANSPORTER_HOME=`xcode-select --print-path`/../Applications/Application\ Loader.app/Contents/MacOS/itms/bin
TEMPDIR=/tmp/itsmp
# Remove previous temp
test -d ${TEMPDIR} && rm -rf ${TEMPDIR}
mkdir ${TEMPDIR}
mkdir ${TEMPDIR}/mybundle.itmsp
# You can see this debug info when you manually do an app upload with the Application Loader
# It's when you click activity
cat <<EOM > ${TEMPDIR}/mybundle.itmsp/metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<package version="software4.7" xmlns="http://apple.com/itunes/importer">
<software_assets apple_id="$APP_ID">
<asset type="bundle">
<data_file>
<file_name>$IPA_FILENAME</file_name>
<checksum type="md5">$MD5</checksum>
<size>$BYTESIZE</size>
</data_file>
</asset>
</software_assets>
</package>
EOM
cp ${IPA_FILE} $TEMPDIR/mybundle.itmsp/${IPA_FILENAME}
"${TRANSPORTER_HOME}/iTMSTransporter" -m upload -f ${TEMPDIR} -u "$ITUNESCONNECT_LOGIN" -p "$ITUNESCONNECT_PASSWORD" -v detailed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment