Codesign in script

I am Archiving my app in Xcode 13.4.1 and signing it for AdHoc distribution using Automatic signing. I then distribute output to directory on my M1 Mac mini running Monterey 12.5.

I install this version of the app on iPhone 16 and it works.

I have a script that uses PListBuddy to change the name of the App and put in a URL for in a user defined field in the Plist for the app to use to retrieve information used in the app. The script is below at bottom.

In the script I then remove the .app/_CodeSignature and copy the mobile provision to the .app/embedded.mobileprovison.

In the script I then use codesign to resign the .app and move it to a directory passed into the script.

I install using DistributionSummary.plist listed below at bottom.

This worked before an unfortunate incident forced me to change the login to the Mac mini which is also the admin user. I had to use the terminal process of “replacepassword” (?) which was done by Apple rep at the physical App Store in my town. This allowed me back into the Mac Mini but sadly invalidated the KeyChain in KeyAccess.

I have downloaded the Apple Development Cert and Apple Distribution Cert from Apple/developer to the KeyChain and the mobileprovision to the directory containing the script.

When I install this app over the air and click on it I, I get “Unable to Install .app - This app cannot be installed because its integrity could not be verified.”

When I click on Get Info on both Certificates it says “This certificate is valid”

When I try to evaluate the certificates in KeyAccess and click on code signing it does not stick and the radio button is blank next time I evaluate it. I think this may be the root of the problem.

Thanks

Script:

#!/bin/sh

unzip XXApp.ipa

/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName $1" Payload/XXApp.app/Info.plist

/usr/libexec/PlistBuddy -c 'Print :CFBundleDisplayName' Payload/XXApp.app/Info.plist

/usr/libexec/PlistBuddy -c "Set :XXApp21URL $2" Payload/XXXApp.app/Info.plist

/usr/libexec/PlistBuddy -c 'Print :XXApp21URL' Payload/XXApp.app/Info.plist

rm -rf Payload/GenApp.app/_CodeSignature

cp XXapps.mobileprovision Payload/XXApp.app/embedded.mobileprovision

codesign -f -s 'Apple Development: MyName (CCCCCC)’ --entitlements entitlements.plist Payload/XXApp.app

zip -qr XXApp21.ipa Payload

rm -r Payload

NEWPATH=$(echo $1 | tr -d ' ')

Mkdir -p $NEWPATH

cp XXApp21.ipa $NEWPATH

DistributionSummary.plist