Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an Xcode .mobileprovision file be 'installed' from the command line?

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 spectacularly useful script from github originally posted at https://gist.github.com/949831

I'm building the app using xcodebuild, and then signing and embedding the mobileprovision file using xcrun.

When I do all this with a mobileprovision file I manually installed into Xcode using the GUI (e.g. double-clicking) it works fine. If I simply try to use a mobileprovision file copied onto the server with SCP it fails (Code Sign error: Provisioning profile '123abc123' can't be found.)

Presumably this is because the file isn't 'installed'.

Is there any way to install the mobileprovision file from the terminal? I'm using SSH so using things such as the 'open' command won't work.

Thanks!

like image 234
Ben Clayton Avatar asked May 01 '12 13:05

Ben Clayton


People also ask

How do I run Xcode on Mac terminal?

Installing Xcode Command Line Tools To install Xcode Command Line Tools, navigate to your device's Terminal app again through Spotlight Search. Then, type “xcode-select –install” into your terminal and hit Enter.

How do I make sure Xcode is installed on my Mac?

In Finder, select the Go pull-down menu, and select Applications. Or just use the short-cut key Command-Shift-A while Finder is active. This should open a new Finder window, showing all the Applications installed on your machine. Look for the XCode icon in the Applications folder.


2 Answers

If you don't want to download external dependencies (like Ben did), the following should work in most cases:

uuid=`grep UUID -A1 -a adhoc.mobileprovision | grep -io "[-A-F0-9]\{36\}"` cp adhoc.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/$uuid.mobileprovision 

Note that a UUID is composed of hexadecimal digits so the correct range is [-A-F0-9] and not [-A-Z0-9].

Bonus: Download and install profiles

Using the cupertino tool, the following snippet downloads all your distribution profiles from the Developer Portal and installs them.

ios profiles:download:all --type distribution  for file in *.*provision*; do     uuid=`grep UUID -A1 -a "$file" | grep -io "[-A-F0-9]\{36\}"`     extension="${file##*.}"     echo "$file -> $uuid"     mv -f "$file" ~/Library/MobileDevice/Provisioning\ Profiles/"$uuid.$extension" done 

cupertino (the ios command) can be installed with sudo gem install cupertino.

like image 77
nschum Avatar answered Sep 18 '22 05:09

nschum


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

like image 27
Ben Clayton Avatar answered Sep 19 '22 05:09

Ben Clayton