1

I'm trying to build and archive my XCode project using following command:

xcodebuild -scheme MyApp -workspace MyApp.xcworkspace clean archive -archivePath build/MyApp
xcodebuild -configuration AdHoc -exportArchive -exportFormat ipa -archivePath "build/MyApp.xcarchive" -exportPath "build/MyApp.ipa" -exportProvisioningProfile "afe33cd1-5e6c-47a6-a315-bd442e43ad95"

It is building successfully but exporting ipa is failling with following error:

error: no provisioning profile matches 'afe33cd1-5e6c-47a6-a315-bd442e43ad95'
** EXPORT FAILED **

I have tried following as well

 -exportProvisioningProfile "afe33cd1-5e6c-47a6-a315-bd442e43ad95.mobileprovision"

I'll appreciate any help in this regard. Thanks

pjs
  • 18,696
  • 4
  • 27
  • 56
Jitendra Singh
  • 2,103
  • 3
  • 17
  • 26

2 Answers2

3

Value of -exportProvisioningProfile should be the exact name of the provision profile in your system, you can copy this exact name from your developer portal also.

  • Adding name doesn't work. Please provide answer with more details. – JainAnk Nov 04 '16 at 16:34
  • Answer is bit confusing. To add details - you have 2 options how to find provision profile: #1 go to your https://developer.apple.com/ account > certificates page > there is Provisioning profiles filter > select "Distribution" > you get list of distribution profiles(you can have multiple) > click on needed one > you get info and the one labeled "Name" is the one you need. #2. go to ~/Library/MobileDevice/ProvisioningProfiles > open needed profile file in text editor >find "name" tag > under it the value is the one you need to provide as your provisioning profile in build command for terminal. – Mindaugas Nov 16 '16 at 12:24
2

Here is how you can fix this:

Step 1)

Find the provisioning profile name:

/usr/libexec/PlistBuddy -c 'Print Name' /dev/stdin <<< $(security cms
-D -i {placeholder})

Replace the {{placeholder}} with absolute path of provisioning profile with profile name.

Example:

/Users/abc/Library/MobileDevice/Provisioning\ Profiles/49a23630-f766-4892-90f0-d9were00f2fc.mobileprovision)

Step 2)

Build ipa from app file

get the provisioning profile name and replace below {profileName}

replace {archiveFile} with the absolute path of .xcarchive file

replace {pathtosaveipa} with path where you want to save ipa

replace {codesigningName} with the certificate name associated with provisioning profile

execute below after replacing the placeholder with actual value

xcodebuild -exportProvisioningProfile "{profileName}" -exportArchive -exportFormat IPA -archivePath "{archiveFile}" -exportPath "{pathtosaveipa}/app.ipa" CODE_SIGN_IDENTITY="{codesigningName}"
JainAnk
  • 205
  • 3
  • 13