Library not loaded when trying to run on Apple M2

I’m getting the following runtime error when I try to run on a simulator, from a Mac with an M2 Max chip.

I followed the Swift instructions at Install the In-App Payments SDK installing manually. I also created the Run Script step with the following under the /bin/sh

FRAMEWORKS="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo $FRAMEWORKS
"${FRAMEWORKS}/SquareInAppPaymentsSDK.framework/setup"

Other threads pointed to not having inserted the Run Script step, which I did, but also tried running the above framework/setup manually with an error

SquareInAppPaymentsSDK.xcframework/ios-arm64/SquareInAppPaymentsSDK.framework/setup
+ OLDIFS=' 	
'
++ echo ''
+ IFS=
+ IAP_SDK_FRAMEWORKS=("SquareInAppPaymentsSDK" "SquareBuyerVerificationSDK")
+ MAIN_FRAMEWORKS_DIR=/
+ SECONDARY_FRAMEWORKS_DIR=
+ for FRAMEWORK_NAME in '"${IAP_SDK_FRAMEWORKS[@]}"'
+ FRAMEWORK_PATH=SquareInAppPaymentsSDK.framework/Frameworks
+ MAIN_NESTED_FRAMEWORKS_DIR=//SquareInAppPaymentsSDK.framework/Frameworks
+ SECONDARY_NESTED_FRAMEWORKS_DIR=/SquareInAppPaymentsSDK.framework/Frameworks
+ '[' -d //SquareInAppPaymentsSDK.framework/Frameworks ']'
+ NESTED_FRAMEWORKS_DIR=/SquareInAppPaymentsSDK.framework/Frameworks
+ '[' -d /SquareInAppPaymentsSDK.framework/Frameworks ']'
+ for FRAMEWORK_NAME in '"${IAP_SDK_FRAMEWORKS[@]}"'
+ FRAMEWORK_PATH=SquareBuyerVerificationSDK.framework/Frameworks
+ MAIN_NESTED_FRAMEWORKS_DIR=//SquareBuyerVerificationSDK.framework/Frameworks
+ SECONDARY_NESTED_FRAMEWORKS_DIR=/SquareBuyerVerificationSDK.framework/Frameworks
+ '[' -d //SquareBuyerVerificationSDK.framework/Frameworks ']'
+ NESTED_FRAMEWORKS_DIR=/SquareBuyerVerificationSDK.framework/Frameworks
+ '[' -d /SquareBuyerVerificationSDK.framework/Frameworks ']'
+ SOURCE_PACKAGE_FRAMEWORK_DIR=SourcePackages/checkouts/in-app-payments-ios/XCFrameworks
+ '[' -d SourcePackages/checkouts/in-app-payments-ios/XCFrameworks ']'
+ IFS=' 	
'
+ OLDIFS=' 	
'
++ echo ''
+ IFS=
+ '[' '' = install ']'
+ find /Frameworks -name '*.framework'
+ read -r FILENAME
find: /Frameworks: No such file or directory
+ IFS=' 	
'

Runtime Error:

dyld[29072]: Library not loaded: @rpath/CorePaymentCard.framework/CorePaymentCard
  Referenced from: <A3C164B9-03E0-3D7E-9E2C-CD01E6DEACEC> /Users/XXX/Library/Developer/Xcode/DerivedData/XXX/Build/Products/Debug-iphonesimulator/SquareInAppPaymentsSDK.framework/SquareInAppPaymentsSDK
  Reason: tried: '/XXX/Build/Products/Debug-iphonesimulator/CorePaymentCard.framework/CorePaymentCard' (no such file), 
  '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/CorePaymentCard.framework/CorePaymentCard' (no such file), 
  '/usr/lib/swift/CorePaymentCard.framework/CorePaymentCard' (no such file, not in dyld cache), 
  '/Users/XXX/Library/Developer/CoreSimulator/Devices/C870A7C4-8F7C-401F-A45E-9E3AED697CED/data/Library/Caches/com.apple.containermanagerd/Dead/temp.0SwYJ5/246F6BC6-4F5E-4DF2-BA9A-872391D4C535/XXX.app/Frameworks/CorePaymentCard.framework/CorePaymentCard' (no such file), 
  '/Users/XXX/Library/Developer/CoreSimulator/Devices/C870A7C4-8F7C-401F-A45E-9E3AED697CED/data/Library/Caches/com.apple.containermanagerd/Dead/temp.0SwYJ5/246F6BC6-4F5E-4DF2-BA9A-872391D4C535/XXX.app/Frameworks/CorePaymentCard.framework/CorePaymentCard' (no such file), 
  '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CorePaymentCard.framework/CorePaymentCard' (no such file)

Have you double checked the following?

1.Check Framework Dependencies:

  • Verify that you’ve correctly added the SquareInAppPaymentsSDK and any related dependencies to your project. Ensure that they are included in your app’s target.
  • Confirm that you have added the CorePaymentCard.framework (or any other required frameworks) to your project and that they are correctly linked and embedded in your app.
  1. Framework Search Paths:
  • Check your Xcode project settings for the “Framework Search Paths.” Ensure that the path to the directory containing the frameworks is correctly configured. It should include the path to the directory where the SquareInAppPaymentsSDK and related frameworks are located.
  1. Check Run Script:
  • Double-check the Run Script that you’ve added to your project. Make sure that it correctly sets up the frameworks. The script you provided seems to reference /Frameworks, but it should point to the location where your frameworks are stored.
    :slightly_smiling_face:

For point 1, there is nothing in the instructions that mentions the CorePaymentCard framework, only the SquareInAppPaymentsSDK.xcframework, which is included. I checked the Intel version and I don’t see that I included it there. I do see that CorePaymentCardResources.bundle inside the Square SDK framework.

For point 2, I only see Search Paths (not Framework Search Paths).

For point 3, when running that script manually, for example “SquareInAppPaymentsSDK.xcframework/ios-arm64_x86_64-simulator/SquareInAppPaymentsSDK.framework/setup” from the command line, that “find: /Frameworks: No such file or directory” error makes me wonder if there is a problem with the script?

I also decided to try installing with CocoaPods (making sure to open the project.xcworkspace file, and making sure the run script phase is located AFTER the [CP] Embed Pods Framworks.

I still get the CorePaymentCard (no such file) error when I try running on an emulator.