Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script installs a .mobileprovision file via bash (no GUI session needed)
#!/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)
#
# IMPORTANT NOTE: You need to download and install the mpParse executable from http://idevblog.info/mobileprovision-files-structure-and-reading
# and place it in the same folder as this script for this to work.
#
# Usage installMobileProvisionFile.sh path/to/foobar.mobileprovision
if [ ! $# == 1 ]; then
echo "Usage: $0 (path/to/mobileprovision)"
exit
fi
mp=$1
uuid=`./mpParse -f ${mp} -o uuid`
echo "Found UUID $uuid"
output="~/Library/MobileDevice/Provisioning Profiles/$uuid.mobileprovision"
echo "copying to $output.."
cp "${mp}" "$output"
echo "done"
@dwelch2344

This comment has been minimized.

Copy link

@dwelch2344 dwelch2344 commented Oct 10, 2013

In case anyone needs this: The blog page for mpParse was down, but I was able to find the source and recompile it. I threw the compiled binary up at https://github.com/dwelch2344/mpParse/blob/master/build/mpParse - though you'll need to strip off the .txt that GitHub adds to the end

@RichardBronosky

This comment has been minimized.

Copy link

@RichardBronosky RichardBronosky commented Nov 27, 2013

Based on http://stackoverflow.com/a/10775025/117471 you can replace

uuid=`./mpParse -f ${mp} -o uuid`

with

uuid=`grep -aA1 UUID ${mp} | grep -o "[-A-Z0-9]\{36\}"`

and make this script require no dependencies.

@rabosaur

This comment has been minimized.

Copy link

@rabosaur rabosaur commented Feb 12, 2014

script gets rather confused when you have more than one developer in the profile. not exactly sure what it should do, though maybe its parse all the UUIDS and generate different data for each dev.

@michaelhogg

This comment has been minimized.

Copy link

@michaelhogg michaelhogg commented May 23, 2014

@mrisoli

This comment has been minimized.

Copy link

@mrisoli mrisoli commented Apr 28, 2015

I replaced the mParse dependency with @RichardBronosky 's grep, and I get a no such file or directory error on the cp command

@bc3tech

This comment has been minimized.

Copy link

@bc3tech bc3tech commented Jan 28, 2016

use xcode's own PListBuddy instead:

uuid=`/usr/libexec/PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< $(security cms -D -i ${mp})_`
@michaelmcguire

This comment has been minimized.

Copy link

@michaelmcguire michaelmcguire commented Feb 19, 2018

@bc3tech you need the UUID, not the application-identifier. Should be:

uuid=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i ${mp})_`
@webdevbyjoss

This comment has been minimized.

Copy link

@webdevbyjoss webdevbyjoss commented Aug 2, 2018

Managed to do this on pure bash by using the following:

uuid=`echo $(security cms -D -i ${mp} | sed -n "/UUID/ s/.*<string>\(.*\)<\/string>.*/\1/p"`
@dougmarcey

This comment has been minimized.

Copy link

@dougmarcey dougmarcey commented Aug 30, 2019

Another "pure bash" option that handles the lowercase uuids:

uuid=`security cms -D -i  | grep -aA1 UUID | grep -o "[-a-zA-Z0-9]\{36\}"`
@csonuryilmaz

This comment has been minimized.

Copy link

@csonuryilmaz csonuryilmaz commented Sep 7, 2019

@dougmarcey Your proposal worked for me but the first portion of the command gives "cms: option requires an argument -- i" error.

I guess, you have forgotten to add $mp parameter. I modified the line as below,

uuid=`security cms -D -i ${mp} | grep -aA1 UUID | grep -o "[-a-zA-Z0-9]\{36\}"`

which works like a charm. 🙂 Thanks for the effort.

@marcos1262

This comment has been minimized.

Copy link

@marcos1262 marcos1262 commented Jul 22, 2020

I had problems with the "~", but worked replacing with "$HOME".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment