Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get name of distribution identity from .p12 file

I am trying to create automated build for Xcode. Till now everything is working just fine. For building the project from command line I am using this command

xcodebuild –project {“xcode_project file path”}–target {“target_name”} –sdk iphoneos –
configuration Release clean build CODE_SIGN_IDENTITY={$distribution_signing Identity} 
PROVISIONING_PROFILE={UUID for provisioning profile}

I want to fetch the UUID and CODE_SIGN_IDENTITY dynamically,

for UUID I am doing

UUID=$(grep "<key>UUID</key>" "$PROVISIONING_PROFILE_PATH" -A 1 --binary-files=text | sed -E -e "/<key>/ d" -e "s/(^.*<string>)//" -e "s/(<.*)//")

Above script code gives me the UUID of any provisioning profile.

I am stuck at getting the CODE_SIGN_IDENTITY dynamically. I know it is of the form like iPhone Distribution: Developer name

How do I extract iPhone Distribution: Developer name from a .p12 file.

like image 563
Ajeet Pratap Maurya Avatar asked Dec 12 '22 16:12

Ajeet Pratap Maurya


1 Answers

You can use the security find-identity command-line utility to list the available codesigning identities on your system:

/usr/bin/security find-identity -v -p codesigning
  1) F188B6FD76D83316FCB2E594940XXXXXXXXXXXXE "Mac App Distribution"
  2) ADDB5E33AC36FEB2CA0F1C3BC71XXXXXXXXXXXXE "iPhone Developer: Stuart M (xxxxx)"
 2 valid identities found

The -v option limits the list to only "valid" identities, and -p codesigning filters it to only codesigning identities, in case you have multiple.

like image 118
Stuart M Avatar answered Dec 23 '22 12:12

Stuart M