Skip to content

Instantly share code, notes, and snippets.

@podkovyrin
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podkovyrin/4e0444457c9507f3272f to your computer and use it in GitHub Desktop.
Save podkovyrin/4e0444457c9507f3272f to your computer and use it in GitHub Desktop.
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