Skip to content

Instantly share code, notes, and snippets.

@swl367
Created August 25, 2014 18:28
find the team identifier and team name for a given distribution provisioning profile
#!/bin/sh
# find the team identifier and team name for a given distribution provisioning profile
function provisioning_identity() {
ORIGINAL_PROVISION="$1"
security cms -D -i $ORIGINAL_PROVISION > "tmp.plist"
TMP_FILE="tmp.plist"
local result=()
for var in TeamIdentifier TeamName ; do
val=$( /usr/libexec/PlistBuddy -c "Print $var" "$TMP_FILE" )
declare -x $var="$val"
for name in ${val[@]} ; do
if [[ "${name}" != "{" && "${name}" != "}" && "${name}" != "Array" ]] ; then
result+=("${name}")
fi
done
done
echo ${result[@]}
#rm tmp.plist
}
#mp contains your provisioning profile path
mp=$1
provisioningarray=$(provisioning_identity ${mp})
result=()
for i in ${provisioningarray[@]} ; do
result+=("${i}")
done
for (( i = 1; i < ${#result[@]}; i++ )); do
echo "${result[i]}"
TEAM_NAME+="${result[i]} "
done
TEAM_IDENTIFIER="${result[0]}"
echo $TEAM_IDENTIFIER
echo $TEAM_NAME
identity="iPhone Distribution: $TEAM_NAME($TEAM_IDENTIFIER)"
echo $identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment