"no valid aps-environment entitlement found for application" - iphone

I am encountering this error when I am loading an Ad Hoc build of my Push Notification enabled iPhone app onto my device:
no valid aps-environment entitlement found for application
What does it mean, and how do I repair it?

I found the solution. In my project info under Build > Code Signing Identity I had it set to automatic, and it was selecting an AdHoc distribution profile which did not have push notifications enabled. (It was the wrong one.) I have selected the correct profile and the error is gone.

Push Notifications must be enabled for your App ID before creating a Provision Profile.
So, in this order:
Create your APP ID
Enable APNS
Create the Provisioning Profile

You have to enable Target—> capabilities—> push notification. I have faced this issue using Xcode 8.1.

In my case Xcode had invalidated the provisioning profile (it will say so in the Member Center).
What worked was to refresh all the provisioning profiles in Xcode after enabling Push for the app in the Member Center.
Here is Apples guide to refresh all the provisioning profiles on your computer. https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html#//apple_ref/doc/uid/TP40012582-CH30-SW26
In short open Xcode and do the following:
In the Xcode Preferences window, click Accounts.
Select your team, and click View Details.
In the dialog that appears, click the Refresh button in the
lower-left corner under the Provisioning Profiles table.
Xcode updates the list of profiles in the Provisioning Profiles table.

Generate a Provision Profile specific for your App ID (Push Notifications Enabled), do not use the widlcard ones

I kept going through the process over and over again with one mistake...
the Provisioning profile i kept on using was DEVELOPMENT this WILL NOT WORK
you NEED to use ADHOC provisioning profile

if you didn't write the original code and aren't 100% sure on how it works, make sure that you have it set up to receive the right type of push notification token. had a problem where the app i was working on was only set up tokens on a release build. it's worth a try if nothing else works and you think your code is set up properly -- find the steps online somewhere to do a ad-hoc build and try it

It'll work even with a development profile but if you add in APN (Apple Push Notifications) after the fact make sure to go into member center and open the provisioning profile again (my said invalid), just opening it and closing it made it valid again and then I updated my profiles in Xcode via settings and everything worked just fine.

In my case, I renamed the App. So the provisioning profile was generated for the old App-ID. All I had to do, was to change the App-ID and add an new provisioning profile with the new App-ID.

For IONIC USERS:-
CAUSE:- If you are running your app in iphone using "ionic run ios" then this will also cause the same problem.
SOLUTION:- instead you must run your ios app using XCODE to install app into iphone.
SOLVED MY PROBLEM!!!!

Related

No Identity with Provisioning Profile in XCode

I'm trying to get my XCode to run apps on my iPhone.
A while ago I tried to do that just from within XCode (knowing nothing), and it complained about how my Apple ID wasn't set up with a developer account. Fair enough.
Now I do have a developer account (I'm a member of an organization). As soon as I got the enrollment email I followed their instructions about setting up the certificates and adding it to my keychain and whatnot.
Then I followed these instructions to try to get XCode set up. When I got to the part about using my device for development, that button wasn't there. But as the instructions say:
If the device was used for development in the past, the “Use for Development” button may not appear. If this happens, click “Add to Portal” at the bottom of the screen instead.
So I clicked "Add to Portal", a provisioning profile appeared in the list, and everything seemed good. I then proceeded to the "Code Sign Your App" section. This is what I see:
I expected there to be a section for iOS Team Provisioning Profile: * or something. And, of course, this means that when I try to run my app it fails with a code signing error.
I've poked around with deleting and re-adding stuff, but this is where I always get stuck. I can provide more information, I just...don't know what you want. How do I proceed?
Thanks.
You can try CMD Shift 2, going to the Devices tab, and refresh the provisioning profiles and/or the team. It should ask you to log in - and hopefully will update your profile for you.
If it doesn't, it's the same every time. Your device needs to be added to the devices on the portal by a team admin. You said you have a certificate. If not using the team provisioning profile, you have to add your certificate to the profile you are using. Then make sure to quit xcode and reopen it after the changes.
Download the certificate and mobile provisioning profile from the developer site. Then double click them to add to your keychain / organizer.

Getting an error from push notification

In my app, I need push notifications. I am implementing all the instructions from the push notifications docs. But I got an error from Push Notification:
Fail To Register For Remote Notifications With Error:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
entitlement string found for application" UserInfo=0x2340a0
{NSLocalizedDescription=no valid 'aps-environment' entitlement string
found for application}
What I am doing wrong?
Generate a new provisioning profile, after you enable Push, and it will work!
I am using Xcode 6.1.1
You don't have to delete or recreate anything. You just have to make Xcode update your active certificates (including the new push notification certificate).
Simply go to Xcode > Preferences > Accounts > pick your Account > pick your Team > View Details
There click the refresh button in the lower left corner. (Also check your code signing in build settings)
I had same problem,I solved it making sure in Built Settings, Code Signing Identity for debug is set to proper Provisioning Profile in which you enabled push notifications.
First, you need to make sure you use an app ID without a wildcard.
Then you need to enable that app for push notifications for development.
Check this tutorial, for example.
Even after you've enabled your app id for push, it might take a couple of hours for it to work.
That was making me crazy. I cross-checked everything but still was getting the same error.
Tried all the other solution given on the web as well.
However, this did the trick for me. I create .mobileprovision file before enable APNS. This was the real mistake.
Resolution of this problem :
Create App ID
Enable APNS
Then create Provision File
If you have created provisioning profile earlier and the you have enabled APNS , you should delete provisioning file from everywhere in your system(XCode,keychain,iTuneConnect). And then create provisioning file again.
I just dealt with this issue. While there are probably a lot of things going on, here is what I learned.
When you make changes to an app ID, such as enabling push notifications, you need to create a new provisioning profile. I must have created my app ID, made a provisioning profile using it and then enabled notifications on the app ID.
Once I removed the provisioning profile from the portal, and device, I made a new one using the modified app ID. Downloaded it, tossed it on my device, wham bam thank you ma'am it worked. Hope this helps people in the future!
This just solved it for me so I will share.
If you update your app id you then must delete the profile from your device, xcode, and developer.apple.com. Then create a new matching provisioning profile that is updated with the new app id settings. Its best to name it something slightly different so you know you are selecting the correct one.
First thing you have to run applcaiton in device.
This is will happen in xcode 3.2.6. Because when you are getting everything perfect. But your application is not registering in your iphone, ipad or ipod. You need to generate a Entitlement.plst file.
Step: First select your project in xcode create a file. Select codesign file named it entitlement.plist(default name).
Put it on resource folder.
Right click open as xml editor.
Then open your provisionfile like your_apllicationName.mobileprovision (which you have created for Apns server ) in textedit mode.
Now copy some lines like the following from your provisioning profile into your entitlements file:
<key>application-identifier</key>
<string>xyz.com.company_name.app_name</string>
<key>aps-environment</key>
<string>development</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>xyx.*</string>
</array>
Save the entitlement.plist file.
Run your applcation you will notify by Apns server.
Make the Profile right.Maybe you do not set the profile.
For me -> go to project settings -> app target -> Capabilities
enable Push Notifications!
Just make sure that you are using the specific provision certificate
go to: https://developer.apple.com/ios/manage/provisioningprofiles/index.action
check the status of your provision certificate, in worst cases just create new one, download it and assigne it to your project again.
Make sure which type of provision you are using, "development" or "distribution"
I got same too. Here is how I solved.
1) Deleted provisioning profiles at ~/Library/MobileDevice/Provisioning Profiles
2) Deleted profiles from Developer Account
3) Created and installed new profiles
Note that regenarating of profiles didn't solve.
ok, a little embarrassing, but sometimes you spend hours on the most idiotic bugs -
so, I run the application on DEBUG mode instead of AD-HOC.
to change that, do:
scheme -> Edit Scheme...
select Run on the left, and change to Ad-Hoc dist under Build Configuration.
*of course you need to have the suitable adhoc provisioning profile under build-setting\code signing as well as the suitable APNS certificate attached to it when you create the provisioning profile.
** once you run it, it'll crush cause its not on DEBUG mode, but you can still run in from the device.
If you're managing more than one apps pushes on one server then consider the following facts.
You need to process a separate private key as a p12 file to prepare pem file and this private key is generated in keychain app when you create a .certSigningRequest file. So, this CSR can be reused for same app upon expiration but a separate is needed for any other app.
I got same error in XCode 4.6.1, It worked for me then I delete the previous APNS profiles from the Mac and redownload the APNS provisioing profile from member center. In Build Settings at target mode, Code Signing Identity should only in Debug Mode as iphone Developer for Release put as nil or delete the developer or distribution.

The entitlements specified...profile. (0xE8008016). Error iOS 4.2

I am getting the 'dreaded' error The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.
(0xE8008016). when trying to deploy my first app to an un-jailbroken device on iOS 4.2.6 (Verizon). The thing is, I do not have a Entitlements file in my project, as I am not distributing it at all, only putting it on one device. I have gone through all the hoops and loops apple puts you through (certificate, device, provisioning) down to the letter, and I cannot figure out what is going wrong.
Can anyone please help me with this problem?
Just came across this issue myself, the problem was that I had a Entitlements.plist file in the project as part of an ad hoc distribution, and its get-task-allow (ie. 'can be debugged') property was set to NO - setting this to YES fixed the issue and allowed the app to run from Xcode4 on the device in development.
Naturally need to set it back to NO for ad hoc distributions, but just thought I'd mention it in case anyone else comes across the same problem.
I had this issue with Xcode 4.2.1.
For me it was nothing to do with Entitlements file, or Ad-hoc...
I was returning to and old project, and I'd forgotten to add my new iPhone to the provision.
Silly mistake, but also a silly corresponding error message... :-/
If you're using react-native, make sure that the Test target has the same provisioning profile as the main one.
I've had this issue with the iCloud entitlements. My problem was that I forgot to enable iCloud for my App ID in the Provisioning Portal.
After enabling iCloud for your App ID, you will need to recreate the provisioning profiles.
Keep your entitlements file in Target> Build Settings > Code Signing > Code Signing Entitlements.
Go to Target > Capabilities.
Toggle On/Off or Off/On one of the capabilities.
Run.
What worked for me was to completely delete the entitlements file, from the groups list, and from the Build Settings in both Project and Target. Then I recreated the entitlements from the Summary tab in the target, and it loaded fine without any error messages.
Just putting in my 5 cents here. For me none of the above worked, so I was forced to stress down and actually look at every part of the process with fresh eyes.
In rushing this I forgot that I was trying to install my app on a totally new device.
So my error was that I hadn't updated my provisioning profile by ticking off my new device int the "Devices" section of the provisioning profile setup in the Provisioning Portal.
Apparently not including your device in the provisioning profile also generates this error message.
None of the many answers fixed the 0xE8008016 Error for me.
But when I chose "Automatic Device Provisioning" in Xcode 4 > Organizer > Devices > Provisioning Profiles, it finally worked.
In my case it was a stupid mistake. I incorrectly set the "Run" scheme to use the "Distribution" build configuration instead of the "Debug" or "Release" one.
Stupid mistake, but it took a while to debug it, so I'm going to add my answer to improve the knowledge base inside stack overflow!
Delete your provisioning profiles, do a 'Clean All', make sure that your provisioning setting are correct, redownload, and try to run again.
Open 'iOS Provisioning Portal' in Safari.
Tap 'Devices' in the sidebar.
Register your device's UDID
Tap 'Provisioning Profiles'
Edit your apps profile.
Select the device your have just added.
Download the .mobileprovision file.
Install it.
Build again.
I had the same problem in my app, after a few month this specific app worked fine.
The problem was that the Capabilities configured in my Xcode project (under Targets -> {ProjectName} -> Capabilities) were not the same as the Capabilities configured in the provisioning profile (you can check that in the Apple member centre under Identifier -> App Ids -> {your app ID}. In the member centre I saw that Game Center is enabled and so in my project I also enabled Game Center. Then the app was able to launch.
I don't know how it worked until now. That's still a mystery :)
For me check the "Automatically manage signing" option in Target solve the problem!
Upgrading to XCode 4 fixed the issue.
Deleting the xcuserdata folder solved my issue. More on that here: https://stackoverflow.com/a/9968884/300694
If you didn't change anything related to certificates (didn't replace or update them) just do a Product -> Clean. It helped me several times. (Xcode 6.2)
I ran into this problem today and I was pulling my hair out trying to figure it out. Like many people here, it would work if I removed the iCloud options in my entitlement file. When I would go to debug the app with the iCloud options enabled then I would get the 0xe8008016 error. This was right after revoking and regenerating new certificates.
So what solved it for me was to turn on iCloud support for the automatically generated Xcode team profile. Log onto the online provisioning tool, go to App IDs, click on Xcode iOS Wildcard App ID, click on edit, enable iCloud by checking the checkbox, and finally clicking Done. Refresh your profiles in Xcode and then it will start to work.
This makes some sense - when you're debugging it defaults to the team profile and the team profile needs to have iCloud turned on.
Happened to me when I was trying to use an app store distribution provisioning profile for local test by mistake. When I used the proper development profile it worked just fine. Maybe this helps somebody too.
This worked for me...
I deleted the Entitlements file from the target.
Deleted the app off all my devices
Cleaned the build in Xcode
*optional delete the provisioning profile and re-add it
Hope it works for you guys too :)
This is what solved my problem: Deleting the path in the Code Signing Entitlements section of the Targets build settings.
My provisioning profile from Apple developer matched my Xcode capabilities but it still wouldn't build onto my device until I did the following:
Remove/Delete the entitlements file from your Xcode project.
Go back to the Xcode capabilities tab
Hit "Fix Issue" button to get Xcode to re-add the entitlements file.
Worked for me, hope it helps someone.
Happened to me on Xcode 8, it was partially caused by the new Provisioning Profile build setting, as in this Xcode version there are two entries for provisioning profile:
Provisioning Profile
Provisioning Profile (Deprecated)
My fault was that I updated only the first one, and the deprecated entry was still pointing to an invalid provisioning profile. Changing both to the same value solved the issue (clearing the deprecated entry should also have the same effect).
In my case, it looks like Xcode (secretly) reset the Scheme.
I found that the build configuration for Archive was set to Release instead of distribution one, and after I changed it to the correct one, it worked.
I think it is better to check the Schemes as well as the build settings.
I had old project and same problem and I solved .
1.Go to summary
2.Summary have keychain groups and delete keychanin
groups's object.
I hope it's will work for you .
Regards.
i'm using xcode 6 and encounter this issue for one particular iphone 4
finally , i go to device => provision profile =>
and then add the profile manually and problem is fixed .
For me in Xcode 5.1 I was getting The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile. when trying to test the app on my device. Device Development Certificate has to expire Feb 2015.
Issue was resolved:
Selected Target->Capabilities, under GameCenter, here I was getting error on GameCenter entitlement as it was not added to project, although first version of application was released via same XCode 5.1 but there were no errors like this before.
Below, a button was given with title Fix Issue. When clicked it added the GameCenter entitlement and issue was resolved.
After wards the screen looks like:
For me, there was nothing to do with certificate. App now runs successfully on the device.
One more potential problem that will throw this error message: If you're using a perfectly valid provisioning profile for you main app, but have an expired or otherwise invalid provisioning profile for your Today widget extension. I imagine it'd be the same for an Apple watch extension as well.
Check all the profiles!
Check KeyChain Access!
In my case I was using the wrong distribution certificate associated with the provisioning profile.
The code I was working on had a different bundleid in the Info-plist than in the Product Bundle Identifier build setting.
I found this because I noticed this message in the device console in the devices view:
MIS: entitlement 'application-identifier' has value not permitted by provisioning profile 'iOS Team Provisioning Profile: com.xxx.yyy'
If you are trying to activate iCloud syncing, you will need to enable iCloud for the AppID that is used to create the development provisioning profile (which Xcode does automatically). You'll also need to enable this for distribution profiles as well.
The tricky part is that when you refresh profiles in Xcode, this does not trigger a renewal of the profiles; they are simply re-downloaded. So in your iOS Provisioning Portal under Provisioning/Development, you'll need to check the profile that is labeled (Managed by Xcode) and delete it (Remove Selected button). Do this for ALL profiles, development & distribution, that you need to regenerate.
Now, in Xcode in the Organizer, delete provisioning profiles that you are about to replace.
Now to get new ones. If you develop for more than one team and only want to refresh a particular one, select the appropriate Team in the left pane under TEAMS, otherwise select Provisioning Profiles under LIBRARY, then select Refresh.
Finally, remove any old provisioning profiles on your device that could conflict with the new ones since profiles are never deleted automatically; newer profiles are simply added to the list.

iPhone -- renew team provisioning profile

In the provisioning portal, the "renew" button for my team provisioning profile is grayed out. And said profile is expired.
How can I renew it?
EDIT: I found the "automatic device provisioning" checkbox and "refresh" button in the organizer in Xcode. But when I select the team profile, check the checkbox, and push the refresh button, I get this message:
An unexpected error occurred. Please try again. If the problem persists, please contact Apple Developer Support (http://developer.apple.com/support).
I suppose I can go to support, but it would still be better to figure out what the problem is without involving them.
I had the same "unexpected error" issue with the Team Provisioning Profile when it expired. I fixed it by deleting it in the Xcode Organizer AND in the ADC Provisioning Portal, then hitting renew in Organizer.
Posting this again here..
OK, I had the same problem with the disabled 'Renew' button against my Team Provisioning Profile.
This worked for me.
1) Deleted the expired Team Provisioning Profile from the Xcode Organizer.
2) Deleted the same thing from the developer provisioning portal.
3) Again from Xcode organizer check marked the auto provision and clicked 'Refresh'. it asked for the credentials and in a few seconds added the renewed Team Provisioning Profile.
4) It also added the new profile in the developer provisioning portal.
Refresh and removing the iOS devices did not help on my installation.
But I found that the error messages was misleading. I am also member of the Mac developer program and after choosing "My Mac" under DEVICES and pressing the (+) Add to Portal button, the error message "Your team has no devices for which to generate a provisioning profile." did no longer appear.
So it looks like the error message covers the Mac and not iOS devices even that the URL at the end of the error message links to the iOS development center.
I had the issue that Xcode didn't refresh or renew it's managed Team Provisioning Profile and tried a very long time. I always hit refresh in the Library->Provisioning Profiles - section. Then I tried out the Teams section and after hitting the refrsh button there my Team Provisioning Profile which was managed by Xcode was renewed successfully. Hope this helps some of you.
One more thing: I used the same Apple-ID in three teams. So maybe Xcode failed to separate them while refreshing.
Do these things if you want to really solve the problem:
(1) Are you using the certificate for which you made provisional profile from your mac? Or you are using the certificate from other mac machine. If that is the thing then please get .p12 file from there and install in your keychain.
(2) If your certificate in the keychain is the same for which you made the provisional profile then it's fine. Otherwise you have to create new provisional profile for the certificate.
(3) Please make sure that you have set the app id in the target > properties > identifier. If no then please set and choose the provisional profile from the target > build > code signing identity.
(4) Then clean and build your project.
If you find any problem then please let me know. I would like to solve this problem.
I fixed it by signing into my Apple ID in XCode->Preferences->Accounts tab
Is the certificate it is based on expired? Did you delete the device it was for?
Try deleting the profile and click Refresh so Xcode re-adds it. Just a guess. I don't know why this would work, but it's worth a try.
Are you pressing the renew button from within Organizer in the latest Xcode version, 3.2.5 beta 3?
Here's the answer to compiling question, however, if anyone else has the answer to the team provisioning profile please post.
You can still compile apps for your device/simulator by creating a developer profile and downloading it to your device.
The key to getting it to work is to make sure the profile is selected in both the Edit Project and Edit Target Settings from the Project Menu. The Target Setting is more specific and usually screws people up. Making sure they are both in sync will help you get things up and running.
From these two menus, check the Build tab and make sure the developer profile is displayed. The default is iPhone Developer and should point to your downloaded profile.
Is there a problem using a different mobileprovision file? I believe you are getting the error on using a different provision file because your Target might be using the older one.
Try this
Get the new mobileprovision file and
in Project's Build properties, set
the mobileprovision to this one
Select the active target and in the
target's Build properties, ensure
that the same mobileprovision is
being used
Compile the app.
See if that helps.
As far as the Team Provisioning profile goes:
Does your console say anything? Are you using Xcode 3.2.5? I'd file a radar at http://bugreport.apple.com. Do you see the Team Provisioning file in the iOS Provisioning Portal? Does it have a green light?
You might try revoking it and letting Xcode create a new one.
As far as getting your app to work
You can always create an app-specific development profile. Choose your certificate and the app you are working on. Also make sure to select your device in the checkbox list.
Then download the profile (once it is ready) and double click on it to import it into Xcode.
If you look at the Xcode organizer, you should see your development profile in the list.
If it's red, that means your certificate has expired
If it's yellow, that means you don't have the private key present to sign using the selected certificate
In the project's Get Info window, under code signing, choose iPhone Developer for both pickers. Take a look at see which one is automatically selected (sometimes you have to manually choose the right one).
Then do a Clean & Build and you should be good to go.
I made the mistake of looking in Wrong place in Organizer.
On the left is LIBRARY then below that DEVICES
I had clicked on my Iphone under DEVICES > Prov profile.
No refresh button there.
Correct place is
On the left in ORGANIZER is Library > Provisioning Profiles
then Team provision Profile is here
Click on it and hit refresh if expired
As always.... "grep -ir profile ." and the cmd line are always your best friend when you want to fix an Apple frustrating, inconvenience and pain in the ass.... Spent almost an hour poking around xcode trying to find that option to enter the new provisioning profile number, and none to be found... Only when I grep'd for it, was I able to fix, yet another apple pain in the ass.... I can't tell you how many times I've spend hours going through xcode, stuck, because it won't compile because of some stupid invalid setting, profile or argument, only to fix it when I fell back on grep & ssed...
This worked for me:
start xcode.
Window->Organizer from menu
Choose "Provisioning Profiles" from DEVELOPMENT menu.
click refresh button
exit organizer
return to xcode main window.
Build->Clean from menu
build and run.
I fixed this by going to the portal and clicking "modify" on all expired profiles. Then click "select all" for devices and submit.

Code Sign Error When Building iPhone Application

I am new to iPhone development. I just registered with Apple for the iPhone Developer Program. When I try to build, I am receiving an error:
Code Sign error: a valid provisioning profile matching the application’s identifier could not be found
I'm not sure what is wrong. I tried browsing the Internet but I get confused. Can anyone help me with what I should do?
At first it seems a complex process, but it's pretty straightforward when you've been through it a few times.
In a nutshell the process is this:
(I'm assuming you've set up your iPhone/iPod touch as a test device)
Via the iPhone Developer Portal
Create an App ID
(give your application a name, this is just for reference on the website and nothing to do with your own build of your application)
enter a string to identify it, like com.yourcompany.appname
(this is important and should be the same as in your .plist file inside Xcode)
Click and Save this
Go to Provisioning
There are 2 provisioning profiles you'll need
a) development - so you can install your application on a test device (i.e. your iPhone / iPod touch)
b) distribution - if you want to sell the application via the App Store
You can create the profiles by selecting your App ID, created in the previous step, from the drop down list and clicking Save
In a few moments (usually, though it can be longer) the certificate is available for download. Download this to your Mac and drop it onto the Xcode icon. Sometimes the development profile doesn't work for me like this and I drop it directly into the Organiser window in Xcode that shows my connected device.
Besides, if you are in a team account, team admin need to edit Development Provisioning Profiles, and add modify your certificates privilege.
In Xcode inside 'Edit Project Settings' you can select the certificate you wish to code sign with. Usually for debug I sign with the development certificate. Follow the instructions on the apple site and clone the release profile and call it something like release and sign this with your distribution profile. (You won't be able to load the app onto your phone with the distribution profile selected)
Make sure you select the target device as Device and not Simulator when building for the App Store!
Hope that helps, it's from memory so apologies if I've skipped some small steps.
xcode top left corner make sure you're running as "similator" "iphone"
Did you set up an iPhone provisioning profile for either development, ad hoc distribution, or app store distribution?
If not go to the iPhone developer program portal, which is linked from the developer.apple.com/iphone. Apple has provided a great series of video tutorials.
Just make sure you install the certificates or the profile won't be selectable in the project configuration. When you download the certificates double-click on them to install.
Possibly more use for others seeing this issue on a previously configured dev environment.
This error is also shown if your provisioning profile has expired, in this case you can go through the steps in Neosionnach's answer or you can go to Organizer, click on the profile and click Refresh.
This was the winner for me when I had this issue.
As of July 2012, you can go here:
https://developer.apple.com/ios/manage/overview/index.action
Then launch the "Development Provisioning Assistant." It walks through all the steps outlined by FiddleMeRagged.
You can use this process to create a Wildcard ID, if you're just looking to test your app on your iOS device and don't need to deploy to the App Store right away.