An alternative to using otool | grep
is to use vtool
(available on macOS 10.15 and later).
For example:
❯ vtool -show-build ./test
test (architecture x86_64):
Load command 10
cmd LC_BUILD_VERSION
cmdsize 32
platform MACOS
minos 12.0
sdk 12.3
ntools 1
tool LD
version 764.0
test (architecture arm64):
Load command 10
cmd LC_BUILD_VERSION
cmdsize 32
platform MACOS
minos 12.0
sdk 12.3
ntools 1
tool LD
version 764.0
As noted in the comments, this does not work on static libraries or object files. From man vtool
:
Currently vtool only operates on final linked binaries, such as executable files, dynamic libraries, and bundles. Because the
executable code in Mach-O final linked binaries cannot be moved or resized, and because the load commands reside between the mach
header and the executable code, there is only a limited amount of space available for vtool to save changes. Set operations that
add or resize load commands may fail if there isn't enough space in the Mach-O file availble to hold the new load commands.
vtool
does, however, let you edit the build and source versions in the mach header, provided there is enough space for your revisions.