'php: command not found Command PhaseScriptExecution failed with a nonzero exit code
I updated to Monterey and I am trying to build my xcode project.
I have a custom php script that runs in Build Phases and I am getting the following error.
/Users/jonathan/Library/Developer/Xcode/DerivedData/SwiftApp-aboxvgocemtxyjcdbgadfktiyxvd/Build/Intermediates.noindex/SwiftApp.build/Debug Dev-iphoneos/SiteSelectedLibraryApp.build/Script-025223DA20C597E100D80A6A.sh: line 3: php: command not found
Command PhaseScriptExecution failed with a nonzero exit code
I have installed php with brew install [email protected]. I can run php in the terminal now but xcode can't seem to find it.
Solution 1:[1]
I ran into the same issue.
After a lot of searching over the internet, I found this solution.
It would help if you went to this library: https://github.com/shivammathur/homebrew-php
Follow these steps:
- On macOS, install Xcode Command Line Utilities:
xcode-select --install
- Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Fetch the formulae in this tap:
brew tap shivammathur/php
- Install PHP 8.0
brew install shivammathur/php/[email protected]
- Once it is installed you need to override the path
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
- Restart the terminal and test your PHP version:
php -v
- After installing you have to link it:
brew link --overwrite --force shivammathur/php/[email protected]
That's it.
Now Xcode will run the PHP script without any error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Darshan |