When you’re building a project it’s common to have ‘debug’ and ‘release’ targets. This is true for iOS. In the past, it was common practice to clone the release environment into ‘Ad-Hoc’ and ‘App Store’ distribution targets setup with the relevant signing credentials (to avoid you switching these credentials every build). The danger here however is that there was a chance that what you were submitting was different to the release build (are all your #defines on, for example?) with care this risk was avoided, but it wasn’t a great situation.
Enter the more modern builds of XCode3. These let you archive builds, and also re-sign them for submission which was a great improvement. So you can build *once* for release, and run it with your dev credentials, then save it as an IPA for ad-hoc beta testing, and finally resign it the third time for appstore submission.
So I am on the verge of deleting my old distribution targets and relying purely on this functionality.
But there is one, nasty, nasty catch. If you have multiple developer accounts (common I guess for any iOS contractor), this process fall apart a little. The golden rule I discovered today after a lot of pain (my only feedback for each failed attempt was an email from Apple stating ‘Invalid Binary’), is:
You can only re-sign the build with a certificate/profile combination that is from the same development team as what it was originally signed with. I was creating the builds for dev with my own credentials, then re-signing them with my company ones, and this is what failed. XCode let me re-sign and upload the build, but then it would be automatically rejected (the ad-hoc builds would also fail).
So the solution is make sure your Debug/Release builds are signed with the developer credentials of the correct project development team. If you do this, then you can re-sign with distribution credentials no worries.
I haven’t investigated this situation in XCode4 yet, but if you are getting ‘Invalid Binary’ or ‘Entitlements not valid’ errors (for adhoc), then try this!