Basically, you need to have maximum privileges in the Provisioning Portal to do the following, so if you don't, get it, and then do this:
- Login and download a developer certificate. If you need to create one, select How To from the menu in the Provisioning Portal under certificates.
- Download a distribution certificate. Again, if you need one, select How To.
- Open both certificates and make sure they open in your Keychain Access
- Select provisioning and download both a developer and distribution .mobileprovision provisioning profile. Create one if necessary using How To
- Make sure you have XCode open and open both .mobileprovisioning profiles. Make sure that they open in the Organizer and show in the status that they are properly linked with a certificate that is valid in the Keychain Access. If they aren't, a flag will pop up, saying something like "There is no valid certificate associated with this profile" in bright red.
- Check your code signing in both the Target and Project areas of your build. Make absolutely sure that both are trying to sign using your distribution profile.
- Make sure that you are building the distribution scheme of your app (You may have to create this).
- Finally set the build device to iOS Device, set the scheme to Distribution, and select Archive. It is imperative that when the program asks you to allow the code signing to use your private key, that you select "Allow" and not "Always Allow," as this is very buggy and often results in code signing errors.
If you need any more help, comment.
Hope this helps!