If you have some kind of a script to build your Xcode project from command line (eg, on Jenkins), there is one of the many useful environment variables you can set to modify the build process: PROVISIONING_PROFILE (I couldn’t find any official documentation regarding this env var). It allows you to pick an exact provisioning profile to use with your ipa archive, if the autodetection doesn’t work for some reason. But you may stumble upon seemingly strange errors.
For example, have you seen an error like this?
1234567
=== BUILD TARGET incredible OF PROJECT astounding WITH CONFIGURATION Release ===
Check dependencies
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “astounding_project_InHouse”, however, no such provisioning profile was found.
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.1'
** BUILD FAILED **
Looking into ~/Library/MobileDevice/Provisioning Profiles/ you can see the file named astounding_project_InHouse.mobileprovision. The fix is the provisioning profile’s filename should be in the form of UUID.mobileprovision.
One more thing. You can use this script to rename the files:
123
for f in *.mobileprovision;do mv "$f"$(grep -a -A1 UUID $f| tail -1 | sed -E 's/.*>(.*)<.*/\1/').mobileprovision;done
And another thing. You can preview some useful info from provisioning profile files with CocoaDeveloper Quicklook Plugin in Finder. Just install it with brew cask install ipaql.
Despite the big changes in Xcode 4 and 5, Apple’s code signing setup still leaves much to be desired.