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.