Detect if macOS app is Rosetta or Native

It’s desirable to run the native version of the app rather than the Rosetta CPU arch translated binary. Determine if an app is native, Universal, or other architecture with lipo:

lipo -archs /path/to/program

lipo doesn’t search $PATH, so you need to provide the full path to the program, which can be done like:

lipo -archs "$(command -v program_name)"

For example

lipo -archs "$(command -v cmake)"

A symptom of running an x86_64 app on an Apple Silicon CPU without Rosetta is like

arch -x86_64 /usr/bin/true

arch: posix_spawnp: /usr/bin/true: Bad CPU type in executable

Or

❯ cmake-3.13.5/CMake.app/Contents/bin/cmake

zsh: bad CPU type in executable: cmake-3.13.5/CMake.app/Contents/bin/cmake