Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download provisioning profile and install them
#!/usr/bin/env sh
# Install cupertino before run this script
# sudo gem install cupertino
# Validate input parameters
#
if [ ! $# == 5 ]; then
echo "Usage: $0 profile_name profile_output_path team_name username password"
exit 1
fi
# Parameters
#
profile_name=$1
profile_output_path=$2
team_name=$3
username=$4
password=$5
# Build command
#
result_command=`ios profiles:download "${profile_name}" --username "${username}" --password "${password}" --team "${team_name}" --type distribution`
if [ $? -gt 0 ]; then
echo "Error: downloading provisioning profile failed"
exit 1
fi
# Extract original profile file name
#
echo "$result_command"
file_name=$(echo "$result_command" | cut -d"'" -f 2)
# Create dir if not exists
#
profile_output_directory=$(dirname "$profile_output_path")
mkdir -p "${profile_output_directory}"
# Move profile to output path
#
mv "${file_name}" "${profile_output_path}"
# Get profile uuid
#
profile_uuid=`grep UUID -A1 -a "$profile_output_path" | grep -io "[-A-Z0-9]\{36\}"`
profile_extension="${profile_output_path##*.}"
# Install provisioning profile
#
cp -r "${profile_output_path}" ~/Library/MobileDevice/Provisioning\ Profiles/$profile_uuid.$profile_extension 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment