Skip to content

Instantly share code, notes, and snippets.

@YOU54F
Created September 13, 2023 17:03
Show Gist options
  • Save YOU54F/69e9abcaa473d332e3638cd6e19a2411 to your computer and use it in GitHub Desktop.
Save YOU54F/69e9abcaa473d332e3638cd6e19a2411 to your computer and use it in GitHub Desktop.
otool tips and tricks for MACOSX_DEPLOYMENT_TARGET (with rust example)

otool tips and tricks for MACOSX_DEPLOYMENT_TARGET

https://stackoverflow.com/a/64864364

% cargo new --lib demo

% cd demo

% echo '[lib]' >> Cargo.toml

% echo 'crate-type = ["staticlib"]' >> Cargo.toml

% unset MACOSX_DEPLOYMENT_TARGET

% cargo build

Older versions of macOS and/or x86 and x86_64

% otool -l target/debug/libdemo.a | rg LC_VERSION_MIN_MACOSX -A2 | rg version | sort | uniq -c
 198   version 10.7

Newer versions of macOS and/or aarch64

% otool -l target/debug/libdemo.a | rg LC_BUILD_VERSION -A4 | rg minos | sort | uniq -c

% export MACOSX_DEPLOYMENT_TARGET=10.12

% cargo clean && cargo build

% otool -l target/debug/libdemo.a | rg LC_VERSION_MIN_MACOSX -A2 | rg version | sort | uniq -c
   2   version 10.12
 196   version 10.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment