Lots of Killed: 9 compilation errors with an M1/Monterey

A couple of days ago I changed laptops from an Intel/Big Sur to a MacBook Pro M1/Monterey.

Since then I've encountered endless endless problems building in Xcode (for iOS).

The very first attempt at building my project after setting up the laptop was successful, but since then builds just fail randomly without making any code changes. i.e. make a build and its successful, change nothing whatsoever and it fails.

Once a build fails it takes an eternity to get it building successfully again, doing a clean, delete derived data, quit/re-launch Xcode doesn't necessarily fix the problem, it might be necessary to do this 3 or 4 times before the build succeeds again. But that build success will only be temporary before it fails again.

The failures are different each time, but one thing they seem to have in common is a Killed: 9 message, here's an example

Script-00DD1BFF1BD5951E006B06BC.sh: line 5: 22679 Killed: 9         ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh Command PhaseScriptExecution failed with a nonzero exit code

I've had about 6 or 7 different random failures in different places, but they all say Killed: 9 Command PhaseScriptExecution failed with a nonzero exit code.

The project used to build fine on the old laptop, its the exact same project/code, the only variable here is the laptop itself and the MacOS.

I've been struggling with this for the last 3 days, the problems are just endless. The build failures are random, like I mentioned a build will work fine one time, then just stop for no reason. They could occur at any random moment in any random component of the project or its dependencies.

Its utterly impossible to proceed like this, I'm the first in my company out of about 100 employees who are going to upgrade their laptops from Intel to Silicon. I will be telling our IT department we absolutely cannot make that switch as things are just unusable and its impossible to proceed with this combination of laptop|OS|Xcode.

I'm on Monterey 12.2.1 | Xcode 13.2.1, but the problem was also present with Monterey 12.0.1|Xcode 13.2.1

Opening Xcode with Rosetta makes no difference to the problems.

I was able to resolve it by a restart (lol)

I've got the exact same issue since 2 weeks on an intel macbook pro. Everything was just fine, I take a week off, and then when I go back I can't compile because everytime Xcode tries to run a script phase it fails with the message "Killed 9". it's not an Xcode issue though as running the same commands in terminal have the same result. For example running the simple "swiftlint" command makes the terminal hangs for like 30seconds, and then the "Killed 9" message appears. Some days i've tried rebooting 4 or 5 times before the commands are correctly executed. And when it works it's never for long. I've even made a clean re-install of mac os in the hope of fixiing this, but it didn't. My macOS version: 12.2.1.

Same issue here. It starts months ago, when I have Big Sur and Xcode 12. Then I've update Xcode and nothing changes, so I also updated to Monterey and the issue is still there. For days I can't build anything, then without any changes it works again. Now I've Xcode 13.2.1 and MacOs 12.2.1. It's frustrating work in this conditions.

We have this problem, too. Monterey, fully up to date as of today. Mini M1. Merely copying binaries can trigger it, where the originals work and the copies do not.

There's a good answer here: https://apple.stackexchange.com/questions/258623/how-to-fix-killed-9-error-in-mac-os

The key is, when copying binaries, to remove the existing destination before the copy. Or, just move if you can.

This works for us.

I was running into this problem on my M1 Pro MacBook. A bandage is to delete the .out file before every time you compile the C/C++ file. The fix to my problem was to completely remove CommandLineTools using:

rm -rf /Library/Developer/CommandLineTools

then reinstalling xcode using

xcode-select --install

I think this problem may be caused when I moved all my files from my intel MacBook to my M1 Pro MacBook. I've been running into quite a few architecture bugs with the switch to ARM.

I tried resetting the binaries and it did fix the issue for me. To reset the binaries for the macOS M1 terminal, you can follow these steps:

  1. Open the Terminal application on your Mac.
  2. Type the following command and press Enter: echo $PATH. This will display the current path for the terminal.
  3. Copy the output of the command and save it in a text editor for reference.
  4. Type the following command and press Enter: echo $SHELL. This will display the current shell being used by the terminal.
  5. If the output of the command is /bin/bash, type the following command and press Enter: nano ~/.bash_profile. If the output is /bin/zsh, type the following command and press Enter: nano ~/.zshrc. This will open the shell configuration file in the nano text editor.
  6. Scroll down to the bottom of the file and add the following line: export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin. This will reset the path to the default macOS path.
  7. Save the file by pressing Control+O, then press Enter to confirm, and then exit the editor by pressing Control+X.
  8. Type the following command and press Enter: source ~/.bash_profile or source ~/.zshrc, depending on which shell you are using.
  9. Type the following command and press Enter: echo $PATH. This will display the new path for the terminal.
  10. Verify that the path is correct by running a command that is installed by default on macOS, such as ls or pwd.

These steps should reset the binaries for the terminal and restore the default macOS path.

Lots of Killed: 9 compilation errors with an M1/Monterey
 
 
Q