Trying to resign App Store .ipa file for Enterprise account

We use our Enterprise account to test our apps and want to resign the app store build so that we are testing the same binary we release. The resigning succeeds and the app installs on our devices, but crashes immediately when run. (The app store build works flawlessly). The error shown in the logs is:

Bootstrapping failed for <FBApplicationProcess: 0x10ba4b3c0; application<com.pra.bundleidtest.qa>:<invalid>> with error: <NSError: 0x282bf1ce0; domain: RBSRequestErrorDomain; code: 5; reason: "Launch failed."> {
  underlyingError = <NSError: 0x282a4b240; domain: NSPOSIXErrorDomain; code: 88>;
}

I can't find anything about this error.

You should be able to resign an app for Enterprise using the app store .ipa file, right?

Can anyone help?

Here's the script I use to resign (no errors and the app installs - the script might not be appearing correctly):

#!/usr/bin/env bash
set -e
set -x

SOURCEIPA="$BITRISEDEPLOYDIR"
SOURCEIPA+="/AppName.ipa"
DEVELOPER="iPhone Distribution: My Enterprise Certificate Name Here"
MOBILEPROV="My Enterprise mobile provisioning file here"
TARGET="$BITRISEDEPLOYDIR"
TARGET+="/QA"

mkdir "$TARGET"

TARGET+="/AppNameQA.ipa"

BUNDLE="com.company.appname.qa"

envman add --key BITRISEDEVIPA --value "$TARGET"

unzip -qo "$SOURCEIPA" -d extracted

APPLICATION=$(ls extracted/Payload/)

cp "$MOBILEPROV" "extracted/Payload/$APPLICATION/embedded.mobileprovision"

echo "Resigning with certificate: $DEVELOPER"
find -d extracted \( -name "*.app" -o -name "*.appex" -o -name "*.framework" -o -name "*.dylib" \) > directories.txt
if [[ "$BUNDLE" != 'null.null' ]]; then
echo "Changing BundleID with : $BUNDLE"
/usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLE" "extracted/Payload/$APPLICATION/Info.plist"
fi
security cms -D -i "extracted/Payload/$APPLICATION/embedded.mobileprovision" > tentitlementsfull.plist
/usr/libexec/PlistBuddy -x -c 'Print:Entitlements' tentitlementsfull.plist > tentitlements.plist
#/usr/libexec/PlistBuddy -c 'Print:application-identifier' t
entitlements.plist > tentitlementsapplication-identifier #save developer application-identifier to file
#/usr/libexec/PlistBuddy -c 'Print:com.apple.developer.team-identifier' tentitlements.plist > tentitlementscom.apple.developer.team-identifier #save com.apple.developer.team-identifier application-identifier to file
var=$((0))
while IFS='' read -r line || [[ -n "$line" ]]; do
#/usr/bin/codesign -d --entitlements :- "$line" > t
entitlementsoriginal.plist #save original entitlements from the app
#/usr/libexec/PlistBuddy -x -c 'Import application-identifier t
entitlementsapplication-identifier' tentitlementsoriginal.plist #overwrite application-identifier
#/usr/libexec/PlistBuddy -x -c 'Import com.apple.developer.team-identifier t
entitlementscom.apple.developer.team-identifier' tentitlementsoriginal.plist #overwrite com.apple.developer.team-identifier
if [[ "$BUNDLE" != 'null.null' ]] && [[ "$line" == *".appex"* ]]; then
echo "Changing .appex BundleID with : $BUNDLE.extra$var"
/usr/libexec/PlistBuddy -c "Set:CFBundleIdentifier $BUNDLE.extra$var" "$line/Info.plist"
var=$((var+1))
fi
/usr/bin/codesign --continue -f -s "$DEVELOPER" --entitlements "t
entitlements.plist" "$line"
done < directories.txt

echo "Creating the Signed IPA"
cd extracted
zip -qry ../extracted.ipa *
cd ..
mv extracted.ipa "$TARGET"

rm -rf "extracted"
rm directories.txt
rm tentitlements.plist
rm t
entitlementsfull.plist
#rm t
entitlementsoriginal.plist
#rm t
entitlementsapplication-identifier
#rm t
entitlements_com.apple.developer.team-identifier

[we] want to resign the app store build so that we are testing the
same binary we release.

The best way to do this is to re-export the app from the Xcode archive. That way you get Xcode (or xcodebuild) to do all the heavy lifting. Manually re-signing an .ipa is possible but it can get very ugly very fast. I support this sort of thing on the Mac and… well… let’s just say I wish I didn’t have to (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I'm doing this from a script so I would be using xcodebuild. Does it recompile the app or just repackage it? Our goal is to be testing the same binary in our Enterprise account as we eventually release on the app store. If the app is recompiled we wouldn't be testing the same build. Where can I get detailed instructions for using xcodebuild?
Trying to resign App Store .ipa file for Enterprise account
 
 
Q