24

Fairly straightforward question - if I have a .framework file, is there a command/tool that can be used to determine the SDK and Deployment Target versions used to create the framework?

Similarly, can this be performed on the application binary stored inside a .app file? I'm looking to automate a script that will go search a list of previously-built apps/frameworks, without having the original .xcodeproj files, and determining their high/low supported OS versions.

Craig Otis
  • 31,257
  • 32
  • 136
  • 234
  • Related: [Determine minimum OSX version a binary was compiled for](https://stackoverflow.com/q/17143373/183120) – legends2k Jul 22 '20 at 18:31

2 Answers2

41

To find out the SDK and Deployment Target of some binary you should explore the LC_VERSION_MIN_MACOSX load command. Use otool -l <some_binary> to see load commands.
Example:

$otool -l my_binary
...
Load command 9
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.7
      sdk 10.8
...

$otool -l /System/Library/Frameworks/CoreWLAN.framework/CoreWLAN 
...
Load command 8
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.8
      sdk 10.8
...

Example with piping to grep:

otool -l my_binary | grep -A 3 LC_VERSION_MIN_MACOSX
catlan
  • 25,100
  • 8
  • 67
  • 78
cody
  • 3,233
  • 1
  • 22
  • 25
  • *Perfect.* I had played around with `otool`, but the flags were dauntingly numerous. My framework was indeed built with both `version` and `sdk` set to 10.8, and I can now confirm that changing the (Compiler Default) to 10.7 produces a better copy. – Craig Otis Jul 04 '13 at 13:29
  • Any tips on doing the same for iOS? Been trying to determine the deployment target of the current Facebook and Crashlytics frameworks used in a project, but this command does not show anything like a min version. – Clafou Sep 23 '14 at 22:23
  • @Clafou sorry, can't help you in that – cody Sep 24 '14 at 07:37
  • @Clafou are you still looking on how to do it for iOS? –  Apr 07 '16 at 00:18
  • @EdgarAroutiounian not anymore, but if you have a solution it would still be useful to share it! – Clafou Apr 07 '16 at 09:16
  • @Clafou the solution is basically the same but you need to get a suite of cross compiler tools, you can get it by folllowing instructions here: http://hyegar.com/2016/02/22/ios-cross-compiler/ and then doing `armv7-apple-darwin11-otool -l ios_binary | grep -A 3 LC_VERSION` –  Apr 08 '16 at 15:10
  • 3
    It works for iOS provided you tell it the arch: `otool -arch armv7 -l libfoo.a`. – bleater Apr 20 '16 at 05:30
  • thanks! however, is there a way to find out the 'Deployment Target' with the stock tools built into macOS? 'otool' is part of the Developer Tools – user1259710 Jan 28 '19 at 21:29
  • 1
    In my case I needed to swap out `LC_VERSION_MIN_MACOSX` with `LC_BUILD_VERSION`, but otherwise this answer worked great. – inspector-g Apr 29 '21 at 18:28
  • I got it to work under Linux with `7z x file.dmg` and `llvm-otool -arch x86-64 -l | grep -A 7 LC_BUILD_VERSION`. The output contains a line starting with `minos` – mxmlnkn Mar 14 '23 at 14:58
6

On Big Sur 11.4 I check with:

otool -l my_binary | grep minos

Output for example:

minos 11.0
Dmytro
  • 1,290
  • 17
  • 21