0

It's possible to embed an Info.plist section into an executable file for macOS.

An example is this searchfs tool.

And if you Get Info in Finder for this file, it'll show the correct version info (here: 1.0.2).

How can I conveniently get this info in a macOS app (using ObjC or Swift)? I'd expect that NSWorkspace would offer such a function but it doesn't seem to.

I don't want to have to scan the file section myself in order to extract the __info_plist section. Is there a better way?

Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
  • You might find the answers to [this question](https://stackoverflow.com/q/7780789/77567) helpful. In particular, look at [the answer](https://stackoverflow.com/a/13381340/77567) discussing `CFBundleCopyInfoDictionaryForURL`. – rob mayoff Jan 23 '23 at 23:23
  • Thanks for the pointer. I had looked for such an answer but had no luck. This makes this one a duplicate, doesn't it? – Thomas Tempelmann Jan 23 '23 at 23:43
  • Yes, unless you need further helping. – rob mayoff Jan 24 '23 at 00:51

1 Answers1

1

One can retrieve the contents of the embedded info.plist with this cmd:

otool -P /path/to/searchfs

Then you can convert that output into a plist (via the CFPropertyList API) and extract the value for the key CFBundleShortVersionString.

However, that is not an efficient way to parse many files in order to get their version numbers.

Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149