[iOS] Remote build fails to Sign ipa correctly and fails the build. (With solution)

So recently we’ve updated to 4.11 preview 5, and I was having issues signing a build ipa.

I was getting the following:

1>      /usr/bin/codesign --force --sign 9A94A149A6AAAC1AE7163D6C26A767484ECE66AF --resource-rules=Submerged/Binaries/IOS/Payload/Submerged.app/CustomResourceRules.plist --entitlements Submerged/Intermediate/IOS/build/UE4_FromPC.build/Development-iphoneos/Submerged\ -\ iOS.build/Submerged.app.xcent --timestamp=none Submerged/Binaries/IOS/Payload/Submerged.app
1>EXEC : warning : --resource-rules has been deprecated in Mac OS X >= 10.10!
1>  Submerged/Binaries/IOS/Payload/Submerged.app: replacing existing signature
1>  Submerged/Binaries/IOS/Payload/Submerged.app: User interaction is not allowed.
1>  Command /usr/bin/codesign failed with exit code 1
1>  ** BUILD FAILED **
1>  The following build commands failed:
1>  	CodeSign Submerged/Binaries/IOS/Payload/Submerged.app
1>  (1 failure)
1>  Execute took 00:00:05.2573007
1>EXEC : IPP error : RPCCommand MakeApp failed with return code Error_RemoteCertificatesNotFound

the issue being the “User interaction is not allowed” where it’s attempting to show the Keychain access Allow dialog.

I was able to find a solution in the following SO answer:

Setting allow all access to the certificate is a good stop-gap measure, however it would be nice if the unlocking of the keychain was part of the build process.

something like:

security -v unlock-keychain -p "$KEYCHAIN_PASSWORD" "$HOME/Library/Keychains/login.keychain"

I’m mainly posting this as a note to others who may have the same issue later.

EXTRA: The other issue I ran into was the Signing certificate MUST live in the System keychain as well as the Login keychain to work correctly.

Which of the link part was the solution?

The top answer was the solution I used.

This was on the System keychain copy of the certificate.