"otool" and "file" can't show architecture of the ".a" file

Apple uses two forms of AR archives. The first one is very similar to the traditional Unix archive ("a.out archive") - basically just a bunch of .o files stuck together with a symbol index in front:

"<!arch>\n"

header 0
SYMDEF entry

header 1
object 1

header 2
object 2

...

To determine the architecture for which this archive is intended, you'll need to extract at least one object file and use file or otool on it. The archive header itself does not have this information. (In fact, the object files are not necessarily all for the same arch, and in theory you may have any kind of files, not just objects, but this is unlikely.) You can use the ar utility to extract individual files from an archive.

The other kind is Apple's own invention. They took the "Fat binary/universal binary" concept used for multi-arch Mach-O executables and used it for the archives. So, a "fat" archive looks like this:

  Fat Mach-O header
  Architecture 1 header --+
  Architecture 2 header --|--+
  Architecture 3 header --|--|--+
  [padding]               |  |  |
  Archive 1 <-------------+  |  |
  Archive 2 <----------------+  |
  Archive 3 <-------------------+

In this case file and otool can look at the fat header and list which architectures are supported.

To create or edit fat files (both archives and executables), you can use the lipo tool.


One alternative is to use objdump from the GNU binutils package (available e.g. via homebrew). On macOS it's renamed gobjdump. Calling it on the archive will display the archive header info, perhaps saving the trouble of extracting the object files (much like you had originally wanted)

> gobjdump -a ./libboost_regex.a
In archive ./libboost_regex.a:
c_regex_traits.o:     file format mach-o-x86-64
rw-r--r-- 502/20 140976 Nov  8 08:03 2018 c_regex_traits.o
cpp_regex_traits.o:     file format mach-o-x86-64
rw-r--r-- 502/20 106424 Nov  8 08:03 2018 cpp_regex_traits.o
...

Late answer, but adding here for future reference.