I\'m trying to automate the process of building apps for our clients using bash scripts running on a Mac Mini Server (OSX 10.7).
My script is based on the spectacul
We run our builds in Jenkins and had a similar problem. Our Ad Hoc provisioning profile changes quite often and we don't want to run around to each of our build slaves installing them in xcode every time they change, so here's what I got to work:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v <path to yourapp.app> -o <path to your .ipa file> --sign "<Name of signing identity>" --embed <path to .mobileprovision file>
The "" is what you see under "Code Signing" section in the Build Settings of your target.
It looks like there hasn't been any recent development on cupertino
. Fastlane
has a tool called sigh
to manage provisioning profiles (create, download, renew, repair): https://github.com/fastlane/fastlane/tree/master/sigh#readme
Looks like Apple added empty line in the .mobileprovision provisioning profile file below each key-value pair and the grep option doesn't not work anymore.
Here's how to retrieve it with PlistBuddy and security using a python script
command = "/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i abc.mobileprovision)"
uuid = os.popen(command).readline().rstrip('\n')
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 TEAM
TEAM="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 PROFILE
PROFILE="profile name"
# Fetch the profile using `cupertino` tool
# you need to run `ios login` once to setup the account
ios 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 it
cp ${PROFILE_FILE}.mobileprovision "$HOME/Library/MobileDevice/Provisioning Profiles/${UUID}.mobileprovision"
# clean
rm ${PROFILE_FILE}.mobileprovision
Easy to adapt to your provisioning needs.
Use fastlane sigh to install a particular provisional file or you can create a new one.
fastlane sigh renew --adhoc -n "provisional-profile-name" --app_identifier "app-identifier" -u "user-name" --ignore_profiles_with_different_name
provisional-profile-name is just name of the profile, doesn't contain the .mobileprovision extension.
To create a new adhoc profile with all the device UUIDs added,
fastlane sigh --adhoc --app_identifier "app-identifier" -u "username"
Fastfile,
lane :build do
sigh(
adhoc: true,
app_identifier: "***APP_ID**",
provisioning_name: "**Profile_name**",
username: "Apple_ID",
force: true,
skip_certificate_verification: true,
)
gym(
#export_options: "exportPlist.plist",
scheme: "**scheme-name**",
export_method: "ad-hoc",
xcargs: "PROVISIONING_PROFILE=$SIGH_UUID",
)
end