Unable to archive the app

Hi While trying to archive the app with the IOS Build I keep getting an error - Code signing “CorePaymentCard.framework” failed.

Kindly help to proceed. I have also enclosed the screenshot for reference.
Screenshot 2024-08-29 at 22.25.22

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Square Developer Documentation
Build on iOS: In-App Payments SDK
Build on iOS: Point of Sale API

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Sure, I’ll check out the provided links.

This error typically occurs when there’s an issue with the code signing of the framework. Here are a few steps you can try:

  1. Ensure that you have the correct provisioning profile and certificate set in your Xcode project settings.

  2. Make sure that the “Automatically manage signing” option is checked in your Xcode project settings.

  3. Try cleaning your project (Product → Clean Build Folder) and then archive again.

  4. If you’re using Cocoapods, ensure that the framework is included in the “Embed Frameworks” build phase of your target.

  5. Check if the framework is set to “Do Not Embed” in the General tab of your target settings.

If the issue persists, you might need to manually sign the framework. You can do this by going to the “Build Phases” tab in your target settings, and adding a new “Run Script” phase with the following command:

codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements --timestamp=none ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/CorePaymentCard.framework

Replace CorePaymentCard.framework with the correct path to your framework if necessary. This script will manually sign the framework with your app’s signing identity.

This answer was reviewed by @Bryan-Square.

The issue is only while archiving the build,Am able to build and run the app. Whenever I add the runscript in the build settings, The build fails to archive and I get the following error - line 132: ARCHS[@]: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code… If the run script is removed I get Code signing “CorePaymentCard.framework” failed.

The error you are encountering, line 132: ARCHS[@]: unbound variable , typically indicates that the ARCHS array variable is being referenced in your script, but it has not been properly initialized or defined. This can happen if there is a conditional logic that skips the initialization of ARCHS under certain circumstances or if the script assumes ARCHS is always set by the environment.

Have you tried any of the following?

  1. Check Initialization of ARCHS: Ensure that the ARCHS variable is properly initialized before it is used. For example:
if [ -z "${ARCHS+x}" ]; then
    ARCHS=()
fi
  1. Add Debugging Output: Add some debugging output to your script to see the state of ARCHS before the line that fails:
echo "ARCHS: ${ARCHS[@]}"
  1. Default Value for ARCHS: Set a default value for ARCHS if it is not set by the environment:
ARCHS=${ARCHS:-"arm64 armv7"}
  1. Ensure Script Compatibility: Ensure that your script is compatible with the shell being used. For example, if the script uses bash-specific features, make sure it starts with #!/bin/bash instead of #!/bin/sh.
  2. Review Conditional Logic: Carefully review any conditional logic in your script that might skip the initialization of ARCHS under certain conditions.
  3. Code Signing Issue: The secondary issue you mentioned, Code signing “CorePaymentCard.framework” failed, suggests there might be a problem with your code signing settings. Ensure that:
  • The correct provisioning profiles are selected.
  • The code signing identity is properly configured.
  • The entitlements file, if any, is correctly set up.
  1. Combine Solutions: If the run script is essential and removing it causes code signing issues, you may need to address both problems together. Ensure that your run script does not interfere with the code signing process and that all necessary variables are properly defined and initialized. :slightly_smiling_face:

Fine @Bryan-Square, Thanks for the guidance … I’ll give it a try and get back here If am facing any further issues.