This one is tricky. But if you need to build an application for intel chips while having an Apple silicon one... You might need to install dependencies "incompatibles" with your current chip.
Requirements
Make sure you have rosetta installed on your system:
$ softwareupdate --install-rosetta --agree-to-licenseRosetta is a tool provided by Apple that runs x86 binaries.
Homebrew installation
You can open a terminal to simulate the architecture x86 by using the following command:
$ arch -x86_64 zshℹ️ This works because /bin/zsh contains 2 versions of the binary. You can verify this by running file /bin/zsh. You can also verify what is your current architecture with the command uname -m.
Then, install homebrew (inside this shell!)
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"ℹ️ Notice that a standard arm64 installation of homebrew installs homebrew in the directory /opt/homebrew, but the x86_64 version will be installed in /usr/local/Homebrew.
Add a configuration for your x86 shell
If you start a shell with rosetta (arch -x86_64 zsh), by default binaries that will load first are ARM. This is because zsh is supposed to act exacly like the version ARM. However that's usually not what you want.
For example, you want to run the x86 version of brew, and in the default configuration, if you type which brew , you will probably see that the version of brew used here is not the right one. You can of course call the right one, directly with:
$ /usr/local/Homebrew/bin/brew --helpBut as a solution, I suggest you to create a new config file: .zshrc_x86. In this file you simply add:
# .zshrc_x86 content, this file must be load manually
# Add exports to x86 binaries before path to others
export PATH="/usr/local/bin:$PATH"And of course, each time you open a shell in x86 architecture, you will need to run this command to load the PATH:
source ~/.zshrc_x86⚠️ Attention
By using brew with rosetta, you may install many dependencies in x86. Which may not be expected but occurs because sometimes brew need intermediate tool, they will be downloaded for x86 architecture.
Tools will be linked in /usr/local/ which is a directory automatically loaded for any terminal. macOS may load x86 tools before ARM ones!
Remember if you doubt about one binary, you can always test a binary using the file command to learn about its architecture.