I have a game in Steam which crashes in ARM-based Macs. The project is pretty old but I managed to get it to build under Rosetta and fixed the crash. My DRM-free version of the game now runs without issues in my M1 Mac.
However, I cannot get the the Steam version of the game to work. In my project the last build phase for the debug build is to run the following script which copies steam_appid.txt next to the executable (this is required for debug builds to run).
cp "./../Projectname/steam_appid.txt" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/steam_appid.txt"
If this script is run, the txt file is copied correctly next to executable but the code signing fails and I get 7 lines of the following error:
changes being made to the file will invalidate the code signature in: /Users/<user>/Library/Developer/Xcode/DerivedData/ProjectName-xxxyyyzz/Debug/Appname.app/Content/MacOS/Appname
and finally
Command CodeSign failed with a nonzero exit code
If I comment out the copying of the steam_appid.txt, the build goes through without errors but then the app won't launch because Steam doesn't find the file:
[S_API FAIL] SteamAPI_Init() failed; no appID found.
Either launch the game from Steam, or put the file steam_appid.txt containing the correct appID in your game folder.
My question is simply: How can I copy the steam_appid.txt next to the executable without it causing to trigger "Command Codesign failed with a nonzero exit code".
This question advises to remove app sandbox, which I did and it didn't help.
From this question I tried almost all the applicable answers with no luck (removing extended attributes with xattr, keychain access lock/unlock, checking automatically manage sign etc.)