Can an Xcode .mobileprovision file be 'installed' from the command line? Can an Xcode .mobileprovision file be 'installed' from the command line? ios ios

Can an Xcode .mobileprovision file be 'installed' from the command line?


If you don't want to download external dependencies (like Ben did), the following should work in most cases:

uuid=`grep UUID -A1 -a adhoc.mobileprovision | grep -io "[-A-F0-9]\{36\}"`cp adhoc.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$uuid.mobileprovision

Note that a UUID is composed of hexadecimal digits so the correct range is [-A-F0-9] and not [-A-Z0-9].

Bonus: Download and install profiles

Using the cupertino tool, the following snippet downloads all your distribution profiles from the Developer Portal and installs them.

ios profiles:download:all --type distributionfor file in *.*provision*; do    uuid=`grep UUID -A1 -a "$file" | grep -io "[-A-F0-9]\{36\}"`    extension="${file##*.}"    echo "$file -> $uuid"    mv -f "$file" ~/Library/MobileDevice/Provisioning\ Profiles/"$uuid.$extension"done

cupertino (the ios command) can be installed with sudo gem install cupertino.


Since asking this question, I've built a solution myself. The secret is to simply copy the file to the ~/Library/MobileDevice/Provisioning Profiles/ folder, but (here's the tricky bit) renamed to [The UUID].mobileprovision.

The UUID is held inside a text part of the file itself (in a plist). Unfortunately, the file also includes binary so 'defaults read' cannot read it. Luckily this guy has built a small command line utility to get the UUID (and some other things out again).

Here's my full working script:

https://gist.github.com/2568707


A compendium of all other answers update_provisioning_profile.sh:

#!/bin/sh## Download and install a single iOS provisioning profile# 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 TEAMTEAM="team id"# Configure the profile name you want to manage# Copy it 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 name as-is and set as PROFILEPROFILE="profile name"# Fetch the profile using `cupertino` tool# you need to run `ios login` once to setup the accountios 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 itcp ${PROFILE_FILE}.mobileprovision "$HOME/Library/MobileDevice/Provisioning Profiles/${UUID}.mobileprovision"# cleanrm ${PROFILE_FILE}.mobileprovision

Easy to adapt to your provisioning needs.