Xcode 6 - How to pick signing certificate/provisioning profile for Ad-Hoc distribution? - ios

To distribute the app to our testers we use Xcode, which we do using the following process:
Archive application
Distribute for Ad-Hoc
Choose provisioning profile
Save the .ipa to a folder
But with Xcode 6, this workflow was changed a bit. I can still select the Ad-Hoc distribution option, but I cannot select the provisioning profile I want. This gives us no control over which signing certificate is used and the provisioning profile configuration (we use push notifications).
By default iPhone distribution signing identity is used and some kind of XC Ad Hoc provisioning profile is generated, which can be seen on image below:
If you click the arrow near provisioning profile, it opens the folder with provisioning profiles.
So my question is:
Is there any way in Xcode 6 to select the provisioning profile used with Ad Hoc distribution?
Thanks!

I was facing same issue, resolved using command line "xcodebuild" tool script, which is preinstalled with Xcode 6 (didn't need to re-install Xcode 5).
http://www.thecave.com/2014/09/16/using-xcodebuild-to-export-a-ipa-from-an-archive/
Script in terminal:
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile 'Provisioning Profile Name'

I had a similar issue when submitting to The App Store. I created an archive, then clicked "submit" and Xcode wanted to automatically sign with the default "XC com.*" wildcard provisioning profile instead of the explicit profile that already had.
To fix this, I just re-generated the profile on the Apple Developer Portal:
1) Go to developer.apple.com and find the distribution provisioning profile you want to use.
2) Select it, click "Edit", re-name the profile, and click "Generate".
3) Download the provisioning profile to the Desktop and drag it onto the Xcode 6 icon.
4) Re-start Xcode 6.
5) Open the organizer window and click "Submit" on the archive you built. Xcode will automatically pick your explicit profile instead of the generic one.

Once you are in Organizer
Select the ad-hoc build and click "Export...."
Select "Save for Ad Hoc Deployment" -> Next
Instead of selecting an organisation from the drop down select "Use local signing asset" -> Choose
Export and save .ipa as before.
Of course you need to have generated, downloaded and installed the ad-hoc provisioning profile.

It seems the last generated provisioning profile wins right now. So you can just re-generate the profile you want and download it and Xcode will use it.
A slightly better approach: set the desired prov profile in your target and use the command line to build your ipa, that works, too.
Here is the script, I'm using:
#!/bin/sh
# Current as working as of 2014/09/22
# Xcode 6
OUTPUTDIR="$HOME/build"
APPNAME="your-app"
SCHEME="your-app"
APP_WORKSPACE="$HOME/Path/To/your-app.xcworkspace"
rm "$OUTPUTDIR/$APPNAME.ipa" #deletes previous ipa
xcodebuild -workspace "$APP_WORKSPACE" -scheme "$SCHEME" archive -archivePath "$OUTPUTDIR/$APPNAME.xcarchive"
xcodebuild -exportArchive -exportFormat ipa -archivePath "$OUTPUTDIR/$APPNAME.xcarchive" -exportPath "$OUTPUTDIR/$APPNAME.ipa"
and my settings:

I couldn't figure this out either - got bit by it when submitting to the AppStore, where it defaulted to a wildcard profile.
I ended up building in Xcode 6, then going back to Xcode 5's Organizer window for the submission. That way it'll prompt you to pick a profile to sign with.

In Xcode 6 (at least 6.1 I am using now)when you are doing the export for ad hoc, xcode 6 will automatically scan if there is any provisioning profile contains all devices registered in the developer account and at the same time match the bundle ID. If no, it will use XC provision profile. Therefore, if you want to use your own profile, for example, for the purpose of push notification, you will need to select all devices in your profile on apple developer portal. I guess that's the reason why some people recreate profile would work and some wouldn't.
btw,use script can export and upload to testflight, but device just can't download it. probably somewhere I got wrong. if anyone knows why it is, pls let me know. tks

This worked for me:
click "View Accounts.." within the "..select a Development Team.."
dialog.
click "View Details.." and find the XC Ad Hoc provisioning profile.
right click on that profile and chose "Show in Finder".
delete the selected profile.
go back to the dialog in step 1.
click "Chose".
click the arrow near provisioning profile to open the provisioning
profiles directory.
delete again the generic profile like in step 4.
click "Previous" button from the "Send [application name] to Apple:" dialog.
select again "Save for Ad Hoc Deployment"
click again the "choose" button.
now you should see the right provisioning profile name.

I have a workaround for this that works for me.
I have both Xcode 6 and Xcode 5.1.1 installed, Xcode 6 is in Applications and Xcode 5.1.1 is in another directory. When I want to do a build I use Xcode 6 to create the Archive. But you can also see the created Archive in Xcode 5.1.1 so I use Xcode 5.1.1 to distribute the Ad Hoc .ipa using the provisioning profile that I want to use. So build using Xcode 6 but distribute using Xcode 5.1.1.

Using local signing assets while exporting solved the issue for me:

The answer from #MrPatol did not work for me.
My working scenario for Xcode 6.3.2
In Member Centre -> iOS Provisioning Profiles
Delete provisioning profile which was set by default when you were trying to build the app (e.g. "XC..."). Create an ad-hoc provisioning profile (not production) with a short name.
In iPhone Configuration Utility -> Provisioning Profiles
Delete the same provisioning profile (e.g. "XC...")
In Xcode -> Organizer
Select the ad-hoc build and click "Export...."
Select "Save for Ad Hoc Deployment" -> Next
Select an organisation from the drop down
Check that your new ad-hoc provisioning profile is selected automatically
Export and save .ipa as before.

Here are the two key points that solved the problem for me.
When you generate the provisioning profile, it needs to be linked to an Explicit App ID that uses the same bundle identifier as your app. A wildcard App ID will not work.
When you export the app for ad-hoc deployment, select Use local signing asset in the dropdown and click Choose.
Xcode will then find the correct provisioning profile by matching up the App ID with the bundle identifier of the app.

In fact, you need to create a new Distribution profile, specific for Ad Hoc Deployment. This can be found in the classic member center, but it is a new type of certificate.
You can then select which devices can be used to test the app as ou would do with a developer profile.
And the newly created certificate will be available when you export your package from the Organizer the usual way.
Alternatively you can use the TestFlight solution provided by Apple with iOS 8 to enable your user to have access to prerelease.

I had the same problem, finally I solved it regenerating the profile that I wanted to use in Xcode 6 including all the devices that I have registered on my iOS Dev account, doing it that way, when selecting export it shows the correct profile and I can do the Ad Hoc export with Xcode 6 without using a script. Hope it helps.

I've been stuck for a while with this ,, but using Crashlytics solved it , build distributed using the selected profile in the build settings of your Xcode project .
hope it helps somebody .

Almost the same problem. After creating an archive for distribution (Product > Archive) you export the archive (click Export...) and choose "Save for Enterprise Deployment"; then "Next". You then select the "Development Team" default (e.g. organisation name) and click "Choose". Finally you will be presented with a summary view that also lists the provisioning profile that Xcode automatically has found (maybe created on-the-fly) for you. This MIGHT be the wrong provisioning profile (typically a wildcard provisioning profile, like "XC: *") and MIGHT be happening because there already is a wildcard provisioning profile on the developer portal. The wildcard provisioning profile MIGHT be used by other older project and maybe it is not wise to just remove the wildcard provisioning profile from the developer portal.
I used a support ticket for this and only got this link back https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringPushNotifications/ConfiguringPushNotifications.html#//apple_ref/doc/uid/TP40012582-CH32-SW1. Not really a big help.
I have found that MrPatol's solution also works for Enterprise Deployment as well and solves the problem for us. I first logged into the developer portal and manually create a provisioning profile that suited my app. Then downloaded and installed the new manually created provisioning profile.

In xcode 7, I couldn't be able to pick adhoc provisioning via
Organizer -> Upload to App Store & Organizer -> Validate
But I could choose via Organizer -> Export
Edited:
Uploading the app after exporting for adhoc to app store for testFlight caused another issue discussed here. So, solution to both these problem is one. Create AppStore provisioning to be able to pick it via organizer and utilize testFlight by uploading to appstore.

I think it's a right way to specify a -exportOptionsPlist option after Xcode 7. It will choose the right provision files like in the GUI export no matter what you specify in project setting.
xcodebuild -exportArchive -archivePath $Archive_Path -exportPath
$LOCAL_PACKAGE_DIR -exportOptionsPlist $Export_Plist_Path
optionPlist file is like this,
<dict>
<key>teamID</key>
<string>MYTEAMID123</string>
<key> teamID </key>
<string>app-store</string>
<key>uploadSymbols</key>
<true/>
</dict>
<plist>
app-store, enterprise, ad-hoc, development are alternative
But you may meet another error after above.
Error Domain=IDEDistributionErrorDomain Code=14 "No applicable
devices found." UserInfo={NSLocalizedDescription=No applicable devices
found.}
It's a ruby problem. Try this shell script, xcbuild-safe.sh
xcbuild-safe.sh xxxxNormalOptionsInXcodebuild bla...
Wait for a moment, another strange error comes.
xcbuild-safe.sh: line 62: shell_session_update: command not found
What's the hell shell_session_update ? Let us work around it. Just define a function before the real xcodebuild cmd, namely at the line 60 or 61.
function shell_session_update() { :; }

In answer to your specific question, no there is no way to select the provisioning profile to be used. What are you attempting to do? (i.e. what does the profile that you want to select allow that the automatically generated one doesn't?)

Related

Xcode 6 - Can't pick signing certificate/provisioning profile for Ad-Hoc distribution. Always taken default

To distribute the app we are using Xcode 6.0.1, where we encountered some issues by using the following process:
Added App-Id and distribution provision profile under developer program.
Chose provision profile under build settings and Archive application.
Chose Export option to do Ad-HocDistribute.
But with Xcode 6.0.1, this workflow was changed a bit. I couls still select the Ad-Hoc distribution option, but I cannot select the provisioning profile which I have created under developer program against my App-ID. There were no listing of provisional profile as we use to do in Xcode 5 version.
The Xcode 6.0.1 has tried to match the provisional profile from the dev-program and it returns message as no matching certificate and it automatically created identity as XC Ad Hoc * profile. Once I chose the Export option the XC Ad Hoc* profile has been created automatically under the distribution provision profile option in dev-program.
Under the provision profile all devices has been selected which I have added and listing total devices under my testflight application. Please assist me how to choose my provision profile which I have already created specifically for my application. Its really consume my whole day.
Xcode wanted to automatically sign with the default "XC com.*" wildcard provisioning profile instead of the explicit profile that already had.
To fix this, I just re-generated the profile on the Apple Developer Portal:
1) Go to developer.apple.com and find the distribution provisioning profile you want to use.
2) Select it, click "Edit", re-name the profile, and click "Generate".
3) Download the provisioning profile to the Desktop and drag it onto the Xcode 6 icon.
4) Re-start Xcode 6.
5) Open the organizer window and click "Submit" on the archive you built. Xcode will automatically pick your explicit profile instead of the generic one.
In Xcode 7 try to select "Use local signing assets" when selecting team. In my case it automatically selected custom Ad-Hoc profile, instead of XC Ad-Hoc*
It's quite tricky but in your app build settings, you don't have the good provisioning and/or the good code signing identity for the archive mode (RELEASE) and maybe be the bad team too. You have to re set all this things and re archive. You know it's good when Xcode show the good certificate.
Hope you will export your application.
Organizer -> Export worked for me as Organizer -> Upload to App Store and Validate were picking Xcode generated provisioning every-time.
Similar topic discussed here.

XCode 6 and Ad-Hoc distribution without XC: provisioning

Yesterday I've downloaded Xcode 6 and now I have got a problem I can't solve. In my member center I've got valid certificate and ad-hoc provisioning (distribution). Till yesterday, in Xcode 5 if I wanted to add my .ipa to TestFlight I was using Archive and selecting my valid ad-hoc profile. I wasn't even logged in in my developer account in Xcode.
Now - in Xcode 6 - nothing is working at all. Ok, I've logged in preferences, Xcode downloaded all my provisionings on Mac, but whenever I choose Export it says that I don't have matching provisioning profile and it's creating new provisioning profile with XC: prefix - which I don't want to use, because it contains all devices I have in member center - even those I don't want to include in my app!
I was trying everything from this threads:
Xcode 6 - How to pick signing certificate/provisioning profile for Ad-Hoc distribution?
Xcode 6 GM creating archive
but nothing is working for me. Maybe I don't understand correctly how it works and there is a trick I have to do but I would like to use provisioning profile defined by me. I was trying to create new provisioning profile, rename the old one, remove all from Mac, drag provisioing profile from desktop to Xcode icon, select correct Provisioning Profile in Build Setting all over again but I'm stuck.
Screenshots here:
My Ad-hoc profile is distribution profile.
There is no way to get Xcode 6.x to use an ad-hoc profile that doesn't contain all of the devices on your team; this is by design.
I have a workaround for this that works for me.
I have both Xcode 6 and Xcode 5.1.1 installed, Xcode 6 is in Applications and Xcode 5.1.1 is in another directory. When I want to do a build I use Xcode 6 to create the Archive. But you can also see the created Archive in Xcode 5.1.1 so I use Xcode 5.1.1 to distribute the Ad Hoc .ipa using the provisioning profile that I want to use. So build using Xcode 6 but distribute using Xcode 5.1.1. It works for me.
Xcode6 will now always create a new AdHoc provisioning profile prefixed with 'XC' when you export an archive for testing (e.g. Hockey App). In order to do this you must always have the latest App Store Distribution certificate and private key in your keychain.
NOTE: You do not have to have this latest distribution certificate selected in your provisioning profile you built the archive with. Also keep in mind you do not need to have an AdHoc provisioning profile to export an AdHoc ipa.
When you export the first time you will probably receive an error saying that you do not have an AdHoc provisioning profile with the following devices/people in it. Just hit 'Try Again' and it will work.
Something else to keep in mind is that when exporting an ipa you are forced to test push notifications through their distribution/production servers as it is using the new self generated 'Distribution XC: AdHoc' provisioning profile.
If you are using Urban Airship like we are you can no longer use development keys for testing. If you look under 'Entitlements' once you get through the steps to export it will show you that 'aps-environment' is set to 'production'. If anyone finds an alternate solution for this let me know.
I was facing similar issue with my distribution license, and the problem was there was "XC" provisioning profile which had the exact same bundle id.
My solution to his was to delete this XC: provisioning profile both from Apple Developer Portal and Xcode -> Preferences -> Apple ID -> View Details -> XC: provisioning profile -> right click Go To Finder -> delete
Hope this helps,
I encountered the same issue. On one of the StackOverflow threads you linked to, a solution was recently added that worked for me.
After you have created the archive, you can export it with a specific provisioning profile from the command line:
xcodebuild -exportArchive -archivePath "~/Library/Developer/Xcode/Archives/{some-date}/{appname date, time.xcarchive" -exportPath {appname} -exportFormat ipa -exportProvisioningProfile "{provisioning profile name}"
Note that the provisioning profile name is just the name, without any path or file extension.
I ran into this today as well.
I ended up removing the XC profile from the developer portal and recreating my other ad-hoc and app store profiles and downloading them again.
After I did this, when I built and tried to submit to app store, the correct App Store profile showed up AND when I went to export for ad-hoc, the correct ad-hoc profile showed up.
Yay ;)
I hit a similar problem and discovered that even if you specify the correct profiles in Xcode the Xcode6 system wants you to have the latest (from member centre) provisioning profile (for each team your account is against). It seems to walk each one in turn before using the one you need and gets blocked if you are absent any provisioning profile for the teams you belong to.
I ran into this.
No solution here worked.
I ended up moving to a command line build using nomad cli shenzen. Its another great open source project by mattt
Now I go into a shell and just type:
ipa build
DONE
They even have options to send the ipa to whatever Ad Hoc service you want. Awesome.
In Xcode 6 (at least 6.1 I am using now)when you are doing the export for ad hoc, xcode 6 will automatically scan if there is any provisioning profile contains all devices registered in the developer account and at the same time match the bundle ID. If no, it will use XC provision profile. Therefore, if you want to use your own profile, for example, for the purpose of push notification, you will need to select all devices in your profile on apple developer portal. I guess that's the reason why some people recreate profile would work and some wouldn't.
My way is much simpler:
I go to the developer - provisioning profiles and re-create my Ad Hoc profile by choosing 'Edit' then 'Generate', download it and install with double-click. When exporting .ipa the correct (mine) profile is chosen.
Apple only uses the last built provisioning profile, obviously.

Xcode attempted to locate or generate matching signing assets and failed to do so

So I'm trying to create an ad-hoc build using existing provisioning profile (that worked before) with Xcode 6.0.1 on Mavericks, but after trying to export this archive, I keep getting the following error:
Do I need to re-create my certificates and provisioning profiles, or is there a better solution? Thanks!
I'm also facing this issue as a 'Team Member' role. The 'You are not allowed to perform this operation' warning leads me to believe that XCode is more strictly enforcing the roles defined here: https://developer.apple.com/programs/roles/
Even though I have access to the signing assets (certificate and provisioning profile), XCode won't allow me to specify them. Try upgrading your role to Team Admin.
Updated 2014-09-29:
After extensive research, I've found it is possible to generate the .ipa using xcodebuild from the command line even as a 'Team Member' role using the following:
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile "Provisioning Profile Name"
credit to 1
Note: As pointed out in the linked article, the "Provisioning Profile Name" is the name specified in the name field of the certificate (viewable from developer.apple.com).
You can automate the process in xcode by including the call into your project build script.
Try to open your console and go to your Xcode project folder then type these commands:
to clean your project
xcodebuild clean -project YourProjectName.xcodeproj -configuration Release -alltargets
to build and archive your app
xcodebuild archive -project YourProjectName.xcodeproj -scheme YourSchemaName -archivePath YourProjectName.xcarchive
You can simply find YourSchemaName in
Xcode > Product > Scheme > Edit Scheme...
finally to create your app .ipa file
xcodebuild -exportArchive -archivePath YourProjectName.xcarchive -exportPath YourProjectName -exportFormat ipa -exportProvisioningProfile 'Your Provisioning Profile Name'
To find Your Provisioning Profile Name please login to Apple Developer Member Center and go to Certificates, Identifiers & Profiles, then click on Provisioning Profiles for iOS Apps. There you will find Your Provisioning Profile Name.
If it does not work try to replace single quote with double one ( ' with " ).
You will find .ipa file in your Xcode project folder.
After this you will able to open your .ipa file in iTunes and install on your iOS device.
I hope it helps!
What's happening: Xcode need to sign build with valid Certificate. It is trying to locate one with no luck. Why? Because before Xcode6, you were allowed to sign AdHoc builds with your's developer certificate. And you were able to, because you have a private key for it. But now you need to sign Ad Hoc builds with Production Certificate. And you don't have a private key for it.
So steps required to make it possible to build from Xcode6 (https://stackoverflow.com/a/26061067/1918302):
Get a private key for your Production Certificate. (You need to export it from Mac keychain it has and import to your's keychain OR Revoke current and Create New production certificate. During creation you'll get one. Quoting here from link above:
BEWARE: revoking an enterprise distribution certificate invalidates all apps that were signed and deployed with that
certificate (official info)).
Create special XC Ad Hoc: Distribution provisioning profile (if you have Admin role in your team on developer.apple.com - Xcode will do this for you).
Set provisioning profile in your project's target -> Build Settings -> Code Signing to this created in step 2.
Done!
OR if those above not achievable, you can make a build using command line tools: https://stackoverflow.com/a/25979784/1918302.
But this seems to me as security hole and I don't believe that this will work for long time.
We were able to work around this problem by simply having one of the admins download the "XC Ad Hoc: Distribution" profile from the dev center, then sending it to the "Team Member" who wanted to build, and letting him manually import it. Since he already had the cert, this was all he needed to be able to do the build and stop getting this error. Existing answers here are correct, but this is a low-friction way to get the last piece of the puzzle for many of us.
In summary, you need this profile and the cert with a private key in your keychain.
For me, it turned out the cause of this was I had not set the project's provisioning profile property as per this answer.
I my case, the problem was App ID. Of course the app did exist in my member center account. The problem was in Capabilities pane. Some of the capabilities had not resolved issue, but the build was succesed. This lead to the situation, when my App ID in member center and Xcode have different capabilities settings.
Removing this dissonance have resolved my problem.
Check it twice, if you have simular issue.
You must define your account in Xcode->preferences->account
It seems that you have define an appleId which is not allowed to access IOS developer account.
Try to sign with that user in https://developer.apple.com/devcenter/ios/index.action and see if that user is allowed in an IOS developer program.
This can happens if you have signed with an iTunes connect. They are different accounts.
I hope this helps!
Your distributed account is not match team .
You must define your account in xcodeproj->Identity->Team ->Add an Account
I was also receiving this error because the Developer Certificate for the machine I was building on had expired.
Even after renewing that certificate, I was unable to Export the Build for App Store release.
Even after following the instructions in the accepted answer and upgrading that Developer account to an admin.
It turns out, that because the Archive was created while that Developer Certificate was expired, that Developer was unable to codesign using the Distribution Profile.
I had to recreate the Archive, after renewing the Developer Certificate, for that machine to be allowed to use the Distribution Certificate (already installed and previously working) to be allowed to codesign the new archive and upload to app store.
Sharing in case anyone else hits this edge case.

Xcode 6 enterprise distribution not working

I am using my company provided enterprise distribution profile (I donot have the userid/password to create the distribution profile) to distribute application. Recently I have upgraded from xcode 5.1 to 6. Since then I am unable to export ipa file. When I chose "Save for Enterprise Distribution" > Next it gives error "You need to add an Apple ID account that is enrolled in the iOS developer program". But earlier I used the same process to export application and used to show a window with company provided distribution profile name. Though it deploy application to my iPhone 5s. I have checked `/Library/MobileDevices/Distribution Profile has the provision profile.
Please let me know what am I missing or I have to do to export for enterprise distribution of apps.
I got the same issue and found this article which helped me a lot about creating an IPA from command line : http://www.thecave.com/2014/09/16/using-xcodebuild-to-export-a-ipa-from-an-archive/
Since you already have your xcarchive created, only the last part is important :
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name”
As mentioned in the article, the “Provisioning Profile Name” parameter is neither the name of the provisioning file nor the UDID, but the name of the provisioning as created in the iOS Dev Center. You can get it from Xcode (it's the name of the profile you used to compile) or using the iPhone Configuration Utility App http://support.apple.com/kb/DL1465
I just hit this same problem. It appears that xcode 6 has added an arbirary restriction on exporting ipas with provisioning profiles that you aren't a team member of. You can get around it by manually exporting and signing using the cli.
http://www.thecave.com/2014/09/16/using-xcodebuild-to-export-a-ipa-from-an-archive/
With the new Xcode 6 we need to log-in using a apple id which is signed in apple developer program or is a member of the apple developer program. Without developer account id we cannot built ipa with new Xcode. I was able to build the app after log-in to the app id.

Test Flight Error: Invalid IPA: missing embedded provisioning profile - How do I fix this?

I'm trying to package my app up and distribute an ad hoc version via Test Flight. I've already packaged and submitted the app to the app store so I'm trying to figure out which settings I need to change to make it work for ad hoc.
When I try to upload my .ipa in Test Flight I get "Invalid IPA: missing embedded provisioning profile"
I tried following the instructions from Test Flight here: http://support.testflightapp.com/kb/tutorials/how-to-create-an-ipa-xcode-4 But there isn't even in option of "Code Signing" for me in Xcode (v4.2).
I've created an ad hoc provisioning profile and downloaded it into Xcode.
I've changed the code signing identity in build settings (for both target and project) and after archive I've attached the ad hoc provisioning profile when sharing the .ipa.
I'm still getting the error. Any thoughts on what else I might need to do?
Thanks.
The entitlements pane is now in project properties -> summary.
I would try cleaning your app, and re-archive. Make sure that Xcode recognizes your AdHoc profile. It can be quite the pain in the ass to get Xcode to pick up your profile due to conflicts in your keychain. Open Organizer, select Provisioning Profiles, and make sure your AdHoc profile doesn't have any issues. If it does, you will probably need to clear out your keychain and profiles and start nice and clean. I have a post on SO that might help you. Use Device Instead of Simulator
If you aren't having any issues with your profiles, try and just attach it after you upload your ipa file to TestFlight.
For anyone who is still experiencing this error:
I was experiencing this issue with XCODE 4.3.
1 . Make sure you have a Ad-Hoc Cert :
YouTube Tutorial
After Archiving and Selecting the Distribute via Ad-Hoc option, Make sure that you Update your list of keys. The option is at the bottom of the list. And select the Ad-Hoc cert if you just had to create one.
i.e. Product > Archive > Distribute > "Save for Enterprise or Ad-Hoc Deployment" >
Next > Code Signing Identity ** Refresh Code Signing identity **
If you are planning on distributing your application via TestFlight you will need an Ad-Hoc provisioning profile generated through your Apple Developer account.
Every application I build has at least 2, often 3, different provisioning profiles assigned to them.
Development
Ad-Hoc for outside testing
Distribution

Resources