Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

ios - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...