I’ve been looking into the best way to go about this as well.
The StackExchange Link mentions using this command:
mdfind "(kMDItemExecutableArchitectures == 'i386') && (kMDItemExecutableArchitectures != 'x86_64')"
This seems to be examining metadata of the binaries somehow, which might not be easy without running an actual command like this unless there is an existing inspector for this, or there is an easy way to read it in the binary.
If the info is in IOReg, that would work. It seems like System Report is getting this info stored somewhere specifically. If we knew how to read that location directly, then that would be an option as well.
From here: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/mdfind.1.html
The mdfind command consults the central metadata store and returns a list of files that match the given metadata query.
What is this “central metadata store”? Does it have something to do with spotlight?
It does seem that
mdfind is the command line interface to spotlight: https://blog.superuser.com/2011/06/03/digging-deeper-mastering-spotlight-in-os-x/
Spotlight saves it’s info: https://superuser.com/a/82109
The location of the newest spotlight index is given in this plist:
Which ends up being:
I was hopeful that Spotlight saves it’s indexes in SQLite, but that doesn’t seem to be the case: https://stackoverflow.com/a/8140658