Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
# 2012 - Ben Clayton (benvium). Calvium Ltd
# Found at https://gist.github.com/2568707
#
# This script installs a .mobileprovision file without using Xcode. Unlike Xcode, it'll
# work over SSH.
#
# Requires Mac OS X (I'm using 10.7 and Xcode 4.3.2)
#
# For the first time it will install mobileprovision-read executable by downloading and
# compiling it using curl and gcc.
# See https://www.github.com/0xc010d/mobileprovision-read and
# http://idevblog.info/mobileprovision-files-structure-and-reading
#
# Usage installMobileProvisionFile.sh path/to/foobar.mobileprovision
MOBILEPROVISION_READ_BIN=${BASH_SOURCE[0]%/*}/mobileprovision-read
if [ ! $# == 1 ]; then
echo "Usage: $0 (path/to/mobileprovision)"
exit 1
fi
if ! [ -f ${MOBILEPROVISION_READ_BIN} ]; then
curl https://raw.githubusercontent.com/0xc010d/mobileprovision-read/master/main.m \
| gcc -framework Foundation -framework Security -o ${MOBILEPROVISION_READ_BIN} -x objective-c -
fi
if ! [ -x "${MOBILE_PROVISION_READ_BIN}" ]; then
echo "Mobile provision profile reader is not valid [${MOBILE_PROVISION_READ_BIN}]"
exit 2
fi
H="[0-9A-F]"
if ! [[ "${uuid}" =~ ^$H{8}-$H{4}-$H{4}-$H{4}-$H{12}$ ]]; then
echo "Invalid UUID found [${uuid}]"
exit 3
fi
mp=$1
uuid=`${MOBILEPROVISION_READ_BIN} -f ${mp} -o UUID`
echo "Found UUID $uuid"
output=~/"Library/MobileDevice/Provisioning Profiles/$uuid.mobileprovision"
echo "copying to $output.."
cp "${mp}" "$output"
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment