Question

I wrote a script that uses xcodebuild to generate an AdHoc build of an iPhone application.

I would like to edit this script to output the name of the Provisioning Profile used to sign the build.
This would allow me to include the Provisioning Profile in the zip that is automatically generated. This way, I could automatically send the archive to the AdHoc testers and be sure that they have the right Provisioning Profile to install the app.

Is there any way to extract the Provisioning Profile name or file used to sign the application:

  • from the builded and signed application
  • from the Xcode project (I don't want to manually parse the project.pbxproj file, as this solution might break in the next Xcode update)
  • any other way that is scriptable

Unforgiven suggested to use the command security to get the name of the certificate used to sign the app. Once you have this information, is there any way to then find the name of the Provisioning Profile?


Here is what I tried:

Sadly, the output of xcodebuild during the build does not contain this information. During the CodeSign step, there is the line:

/usr/bin/codesign -f -s "iPhone Distribution: My name" ...

but I can't match this with a certificate.

I looked into using codesign, and the command

/usr/bin/codesign -d -vvv --entitlements - -r - /Users/lv/Desktop/TicTacBoo.app/TicTacBoo
looked promising, but it doesn't give me the information I need.
I haven't found any useful option in xcodebuild either.

Was it helpful?

Solution

The provisioning profile is already in the application. You don't need another copy in your zip file (unless your testers do not understand how to use the copy inside of the application.)

It's named YourApplication.app/embedded.mobileprovision

This doesn't answer your question because the original filename is lost, however it does seem to solve your bigger problem.

OTHER TIPS

You can use the "security" command from the terminal; unfortunately, at least on my MBP with Snow Leopard it appears to cause a segmentation fault in one of the commands you need to issue. For more information, issue from the terminal

man security

Anyway, here is what you can try, assuming your development/production certificates are stored in the login keychain:

security unlock-keychain login.keychain;
security find-certificate -a -c "iPhone Distribution: Your name"  -p > cert.pem;

The second command causes the segmentation fault (caused by the -c argument), but it should be exactly what you need. Alternatively, you can use

security find-identity -p codesigning -v;

to get a list of all of the valid certificates you can use to code sign your applications. For each certificate, the output also contains the SHA1 message digest, so that you can easily search the certificate in the keychain matching the SHA1 digest associated to "iPhone Distribution: Your name". This however, requires that you write your own application using the keychain APIs.

Let me know if this works on your mac or if you experience the same segmentation fault issue.

EDIT/UPDATE: I have verified the bug on other machines and filed a bug to Apple.

How about looking in the _CodeSignature/CodeResources plist file (of the built application) for files of type "mobileprovision"?

Here's a way to do that using defaults(1) to read the plist file. You have to copy the CodeResources file to something with the ".plist" suffix to keep defaults happy...

cp /build/Distribution-iphoneos/MyApp.app/_CodeSignature/CodeResources /tmp/defaults.plist
defaults read /tmp/defaults files |grep .mobileprovision |grep -v embedded.mobileprovision

(in my test case, there were 2 .mobileprovision entries there; ignore the one named "embedded.mobileprovision")

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top