'Xcode 13.2 command PhaseScriptExecution failed with a nonzero exit code

While building my project, I get this error:

line 2: /usr/local/bin/carthage: No such file or directory. Command PhaseScriptExecution failed with a nonzero exit code

Tried so many methods to resolve this issue, including switching Xcode versions. It's worth to mention that it only occurs on an M1 Mac device which I'm currently using, same project without changing any part of the configurations works on an Intel Mac.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source