0

I've got a M1, with XCode 13.2.1 and monterey.

I've installed brew following the official steps and also I did the extra two steps so the new brew path is added to my path.

Additionally I've added export PATH=/opt/homebrew/bin:$PATH to my .zshrc

I've installed protobuf and swift-protobuf with brew and I can run both in the terminal with no errors.

But when I use protoc in a custom script in XCode build rules, I get the following error:

/bin/sh: protoc: command not found
/bin/sh: line 7: protoc: command not found
/bin/sh: line 9: protoc: command not found

I could add the path of protoc which I got from which protoc but I'm not sure if that would make a problem for other architectures.

Any idea why if protoc is running in my terminal, it's not running in custom script in XCode Build Rules?

xarly
  • 2,054
  • 4
  • 24
  • 40
  • Looks like you XCode script didn't find the protoc on path. Try to add `export ...` to `~/.bash_profile` or add to your script. – HelloWood Mar 15 '22 at 02:14
  • 1
    I end up exporting the `hombrew` path if it exists: `if [ -d "/opt/homebrew/bin" ]; then export PATH=/opt/homebrew/bin:$PATH fi` – xarly Mar 16 '22 at 16:56

1 Answers1

0

Go to

/usr/local/bin

if there isn't the bin folder create it. Maybe it doesn't work from terminal, you can do it from Finder

After that go to the folder from the terminal and write

sudo ln -s /opt/homebrew/bin/protoc protoc

and

sudo ln -s /opt/homebrew/bin/protoc-gen-swift protoc-gen-swift

Quit Xcode, clean build folder and retry

Luca
  • 13
  • 6