Assumptions:
- .ipa filename is app.ipa
- app is called MyApp
- new provisioning profile resides at: ~/Downloads/AdHoc.mobileprovision
- distribution certificate name is Company Certificate
- may not need resource-rules parameter
- provisioning profile is either for Adhoc, or Enterprise distribution
Commands:
unzip app.ipa rm -rf Payload/MyApp.app/_CodeSignature/ cp ~/Downloads/AdHoc.mobileprovision Payload/MyApp.app/embedded.mobileprovision codesign -f -s "iPhone Distribution: Company Certificate" --resource-rules Payload/MyApp.app/ResourceRules.plist Payload/MyApp.app zip -qr app-resigned.ipa Payload/