Permission denied when executing Bundle React Native script

I’m receiving a “Permission denied” when trying to run the pipeline after the compiling steps of my app for ios. It’s failing when trying to execute a bundle react native script which apparently doesn’t exist before the build because I can’t use a chmod command to mark it as executable. The config.yml is identical to the version at the Mattermost github here: mattermost-mobile/config.yml at main · mattermost/mattermost-mobile · GitHub. I’m at my wits’ end with this issue here and don’t really know what else to try anymore. The specific error I get is the following:

▸ Linking Mattermost
▸ Generating ‘Mattermost.app.dSYM’
▸ Running script ‘Bundle React Native code and images’
** ARCHIVE FAILED **

The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/distiller/Library/Developer/Xcode/DerivedData/…/Mattermost/IntermediateBuildFilesPath/Mattermost.build/Release-iphoneos/Mattermost.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target ‘Mattermost’ from project ‘Mattermost’)
(1 failure)
Exit status: 65

If you need additional information please let me know, any kind of help is greatly appreciated.
Edit: The title of the step is ‘Run fastlane to build iOS’.

To allow someone to provide some help can you post the ‘title’ of the step that shows the error. This relates to the name: parameter given to each step in the script and so makes it easier to find the section throwing the error.

One thing that comes to mind is that Exit Code 65 if thrown by iso shell may indicate that something is not installed - so the error may relate to something that the script tries to call, rather than it being an issue with access to the script. I do not know anything about iso as I do not use it, but the issue is documented here

I’ve added the title of the step in my post above, it’s called “Run fastlane to build iOS”.

Unfortunately the provided link didn’t really apply as I’m using the setup_circle_ci command in my Fastfile to create a keychain and as far as I’m aware, it should have the required access rights from the get-go. This is the corresponding step in the logfile:

–Step: setup_circle_ci
Skipping Log Path setup as FL_OUTPUT_DIR is unset
Creating temporary keychain: “fastlane_tmp_keychain”.
$ security list-keychains -d user
▸ “/Users/distiller/Library/Keychains/fastlane_tmp_keychain-db”
[ Found keychain ‘/Users/distiller/Library/Keychains/fastlane_tmp_keychain-db’ in list-keychains, adding to search list skipped
Enabling match readonly mode.

the pod install command is also being run. I also don’t get any error messages regarding keychain or password mismatch. I can see the tmp_keychain as well as it’s password being set in the summary for match. It all seems to work flawlessly until I reach the step I posted above. The only additional info it’s giving me is a “permission denied”:
▸ /bin/sh -c /Users/distiller/Library/Developer/Xcode/DerivedData/…/Mattermost.build/Debug-iphoneos/Mattermost.build/Script-00DD1BFF1BD5951E006B06BC.sh
▸ /Users/distiller/Library/Developer/Xcode/DerivedData/…/Mattermost.build/Debug-iphoneos/Mattermost.build/Script-00DD1BFF1BD5951E006B06BC.sh: line 2: ./bundleReactNative.sh: Permission denied
▸ Command PhaseScriptExecution failed with a nonzero exit code
changing the export option to Release instead of Debug didn’t change anything (except for the corresponding folder name). I’ve also tried reverting back to an older version of Xcode but it still fails at the same step, it just doesn’t show any additional info, so the line about “permission denied” is missing with older version.
The Fastfile being used is also the one from the official Mattermost Github I’ve linked in my original post.

Update: I managed to build it successfully after switching from Mattermost version 2.3 to 2.4 and doing everything from scratch again. I think the main solution was that I didn’t realize that the sh files it’s trying to call already existed within the ios folder (while the build is being done from the fastlane folder) so I could successfully use chmod on them.