Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pcuenca/1b5027210690cb650c43 to your computer and use it in GitHub Desktop.
Save pcuenca/1b5027210690cb650c43 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Download and install iOS provisioning profiles
# Requires https://github.com/nomad/cupertino
#
# Usage
# - Login to your account once:
# ios login
# - Configure TEAM and PROFILE (instructions below)
# - Run update_provisioning_profile.sh at anytime, usually after adding/removing devices to the profile
# Configure the team identifier
# Copy it from developer portal or just use cupertino to get it:
# ios devices
# Copy the string in parens and set it as TEAM
TEAM="team id"
# Configure the profile names you want to manage
# Copy them from developer portal or use cupertino to get a list (ignoring Xcode managed profiles):
# ios profiles --team ${TEAM} | grep -v 'iOS Team Provisioning Profile'
# Copy the desired profile names into the PROFILES array
PROFILES=( "Profile One" "Profile Two" "Profile Three" )
num_profiles=${#PROFILES[*]}
typeset -i profile_idx=0
while [[ $profile_idx -lt $num_profiles ]]
do
profile=${PROFILES[$profile_idx]}
let profile_idx=$profile_idx+1
# Fetch the profile using `cupertino` tool
# you need to run `ios login` once to setup the account
ios profiles:download "${profile}" --team ${TEAM}
PROFILE_FILE=`echo $profile | tr ' ' '_'` # `cupertino` tool will replace spaces with _
UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i ${PROFILE_FILE}.mobileprovision)`
# copy where Xcode can find it
cp ${PROFILE_FILE}.mobileprovision "$HOME/Library/MobileDevice/Provisioning Profiles/${UUID}.mobileprovision"
# clean
rm ${PROFILE_FILE}.mobileprovision
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment