Search code examples
x86arm64otooldeployment-targetlipo

arm64/x86_64 universal binary created with lipo is missing deployment target


Context

I'm converting several libraries/frameworks that my Mac app uses to be Universal Binaries for the new Apple Silicon Macs.

Problem

I have two versions of a binary framework: one compiled for x86_64 and one compiled for arm64. I always check the frameworks with otool to make sure the minimum deployment target is set correctly. To do that, I use this command:

otool -lv myIntelX86Library.a

In the output, I see exactly what I expect:

Load command 1
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.12
sdk 11.0

Running the same command on the arm64 binary produces a minimum version of 11.0, but that's also expected because no earlier version of macOS supports arm64.

However:

Once I combine these two libraries into a fat binary using:

lipo -create <pathToIntel.a> <pathToArm.a> -output <pathToUniversal.a>

When I run otool -lv on the Universal Binary, I can no longer find the LC_VERSION_MIN_MACOSX command anywhere in the output. It does not appear.

How can I verify that the x86_64 part of a fat binary has the correct deployment target set? Thank you.


Solution

  • Well, as usual, it's RTFM. When run on a Universal binary, otool's default is to print information for only the host architecture. To print the load commands for the x86_64 architecture when running on an arm64 machine:

    otool -l -arch x86_64 <pathToUniversalLibrary.a>
    

    Alternately, to print information for all platforms at once:

    otool -l arch all <pathToUniversaLibrary.a>