Just spent a hour or so doing this and with the help of Brad's advice and a few additional changes it all worked.
I've done this using the following: 10.7.3, Xcode 4.3.2, iOS 5.1 btw.
1) Right click on your myapp.xcodeproj
and select package contents
2) open project.pbxproj
with a text editor (don't recommend textedit as it may screw up the formatting)
3) Scroll all the way down until you find /* Begin XCBuildConfiguration section */
4) Notice that you have a debug and release sections
5) In the release section take a look at CODE_SIGN_IDENTITY
& "CODE_SIGN_IDENTITY[sdk=iphoneos*]"
it should look something like this:
CODE_SIGN_IDENTITY = "iPhone Distribution: MyCompany LLC";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: MyCompany LLC";
6) Take a look at PROVISIONING_PROFILE
and "PROVISIONING_PROFILE[sdk=iphoneos*]"
they should look like this:
PROVISIONING_PROFILE = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
This should match your provisioning profile in Xcode. To see if they match open Xcode > Window > Organizer > Devices > Provisioning Profiles > Right click on the profile > Reveal in Finder > The filename of the .mobileprovision is your profile id.
7) Scroll down in the project.pbxproj
and find a second instance of the release section. The second instance of the release section should end with a comment saying /* End XCBuildConfiguration section */
8) make sure that the second section matches the first section so that CODE_SIGN_IDENTITY, "CODE_SIGN_IDENTITY[sdk=iphoneos*]
, and PROVISIONING_PROFILE
are all filled in.