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 attached along with the character 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 need to extract at least one object file and use file or otool on it. The archive header itself does not contain this information. (In fact, the object files are not necessarily all for the same arch, and in theory you can have any files, not just objects, but this is unlikely.) You can use the ar utility to extract individual files from the archive.
Another view is Apple's own invention. They took the Bold / Universal Binary concept used for Mach-O multicast files and used it for archives. So, the bold 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 bold header and list of supported architectures.
To create or edit fat files (both archives and executables), you can use the lipo tool.
source share