Fredrik Andersson Fredrik Andersson - 4 months ago 49x
iOS Question

Provide xcodebuild with .mobileprovision file

I am setting up Jenkins for automating iOS builds. Are there any possibility to provide a .mobileprovision file that is not added to the provisioning tool in Xcode to xcodebuild?

I know that I can use PROVISIONING_PROFILE and PROVISIONING_PROFILE[sdk=iphoneos*] but they require the provisioning profile to be added to the Organizer.

I know that I can do the operation with xcrun. But before running xcrun I must successfully sign the app with xcodebuild.

Is there any way that I can just provide the provisioning profile file (.mobileprovision) to xcodebuild?


We have a solution for this - essentially what you need to do is to 'install' the .mobileprovision file by copying it to a directory named after the UUID of the mobile provision file. This is what the Xcode Organizer actually does when you double-click a .mobileprovision file.

There's a little program called mpParse that can extract the UUID from the mobileprovision file that the script uses - link for download in the code. Then it's dead simple to copy the mobileprovision file to the correct place.

Here's a shell script I made to do this:


# 2012 - Ben Clayton (benvium). Calvium Ltd
# Found at
# 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
# and place it in the same folder as this script for this to work.
# Usage path/to/foobar.mobileprovision

if [ ! $# == 1 ]; then
 echo "Usage: $0 (path/to/mobileprovision)"


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

echo "Found UUID $uuid"

output="~/Library/MobileDevice/Provisioning Profiles/$uuid.mobileprovision"

echo "copying to $output.."
cp "${mp}" "$output"

echo "done"

You can download the script direct from

Once you've run the script, you can use PROVISIONING_PROFILE and PROVISIONING_PROFILE[sdk=iphoneos*] in xcodebuild to create your app. We use this in production.

Edit: Just for reference, I asked essentially this question here a little while back ( Can an Xcode .mobileprovision file be 'installed' from the command line? ) and came up with the above when no-one seemed to know :-)

Update: As an alternative to mpParse one could use apple tools: /usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin <<< $(security cms -D -i path_to_mobileprovision)