简体   繁体   中英

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 php@8.0. I can run php in the terminal now but xcode can't seem to find it.

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/php@8.0
  • After installing you have to link it:
brew link --overwrite --force shivammathur/php/php@8.0

If this command throws an error, then select any one path it shows on the terminal and execute it: For me, I selected this path to override:

echo 'export PATH="/usr/local/opt/php@8.0/bin:$PATH"' >> ~/.zshrc
  • Restart the terminal and test your PHP version:
php -v
  • Now check with this command, does it gives you the waring of already linked :
brew link --overwrite --force shivammathur/php/php@8.0

在此处输入图像描述

That's it.

Now Xcode will run the PHP script without any error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM