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?
File used by Apple Xcode, a software development IDE often used for creating iPhone apps; contains a provisioning profile, which allows an app to be uploaded to a limited number of iPhones or iPads while it is still in development.
Since Xcode 9, Apple provides automatic code signing identity management from the command line by using the xcodebuild command. Using the “allowprovisioningupdates” flag, you can enable code signing; however you may get errors like: Your session has expired.
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:
#!/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=`/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 https://gist.github.com/2568707
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With