Search code examples
iosmach-ootool

Splitting a multi-architecture Mach-o binary


I've downloaded and decrypted (using dumpdecrypted) an iOS application from the app store (let's call it myApp). When I run "otool -arch all -Vh myApp", I get the following result:

myApp (architecture armv7):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00     EXECUTE    76       7140   NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK PIE
myApp (architecture arm64):
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64   ARM64        ALL  0x00     EXECUTE    76       7888   NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK PIE

I would like to be able to split the binary file into two files, one per each architecture. I guess it can be done by parsing the Mach-o headers, but I couldn't figure out how.

Thanks.


Solution

  • The easiest way is to use lipo and the command line option -thin. E.g.

    lipo -thin armv7 -output myApp_armv7 myApp