Skip to content

Invalid arm64 header type #21

@rafaelbaraldi

Description

@rafaelbaraldi

Hi,

First of all, thank you for this script and for the explanation at the blog!
I do not understand why Apple doesn't let you link device arm64 binaries for simulador arm64 version :(

Well, my problem here is that I'm getting this error below:

Arm64ToSimLib/Transmogrifier.swift:49: Fatal error: The file is not a correct arm64 binary. Try thinning (via lipo) or unarchiving (via ar) first.

I was using a static library that is a fat binary containing armv7, armv7s, i386, x86_64 and arm64 architectures, let's call it "library.a".
lipo -info library.a Architectures in the fat file: library.a are: armv7 armv7s i386 x86_64 arm64

As the error above indicates, I tried to extract from this library only the arm64 slice. I tried it with lipo -extract and also with lipo -thin. Both cases generated me a new library with only arm64 architecture. But it still shows me the same error.
I also tried unarchiving the static library object and generating a new library with only arm64 using ar command as follows but it didn't work either:

lipo -extract arm64 library.a -o newLibrary.a

lipo library.a -thin arm64 -output newLibrary.a

ar -xv library.a; ar -rc newLibrary.a *.o

I edited de code for arm64-to-sim binary to print the mach_header_64 properties, the result is the following:
header: mach_header_64(magic: [1918975009](tel:1918975009), cputype: 171862115, cpusubtype: 841953571, filetype: 538976304, ncmds: 538976288, sizeofcmds: 538976288, flags: 926430769, reserved: 892941365)

I was not able to match this values with any static value from Swift MachO library like CPU_TYPE_ARM64 that is expected in this script.

Am I missing something here? Should I be using a different kind of binary files for this script?

Again, thank you so much for your help. This behavior should be de default for Apple stuff, I’m tired to see answers like remove arch arm64 for simulador or to use Rosetta 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions