2

I have a "fat" framework built for iOS, which is being used in a debugging tool built for macOS. Previously I was linking this framework statically, which worked, even though XCode complains about it being built for the simulator (since the architecture is the same). But now, newer versions of the library are dynamic, so that route doesn't work, as the tool is a command line application, which doesn't support embedding frameworks.

I could turn it into an application bundle, it seems, in order to solve that, but I'm not sure what this entails (creating a new project?). I can certainly figure it out but ..

In the meantime, I thought I'd load the library dynamically using dlopen() etc and retrieve the classes/methods I need (I already have some code for this which at least compiles). However, that call fails with the following message:

no suitable image found.  Did find:
/<path to library file>: mach-o, but built for simulator (not macOS)

Since linking statically is only a warning and actually works, is there a way to make dlopen work as well?

Recompiling the framework itself is not an option for me in this situation.

tacospice
  • 647
  • 5
  • 20

1 Answers1

0

Are you considering editing the binary of the dylib framework? If so in the Macho-O header you could try changing LC_VERSION_MIN_IPHONEOS to LC_VERSION_MIN_MACOSX.Probably it won't be enough,but it's a simple change for a quick test. Here's a screenshot comparison of those load commands in MachOView enter image description here

Also covered the other way round here

Community
  • 1
  • 1
Kamil.S
  • 5,205
  • 2
  • 22
  • 51
  • Nice! Unfortunately I won't be able to try this until Tuesday, but then we will see. – tacospice Apr 29 '17 at 17:14
  • Unfortunately #2: MachOView crashes after it finishes loading the library file – tacospice May 02 '17 at 07:33
  • Alternatively you could use console `otool` or `jtool`. Btw `MachOView` is for visualising only, you could still do the change in hex editor if you know what you're doing. – Kamil.S May 02 '17 at 08:14
  • Sadly I do not know what I'm doing. Judging from the screenshot, the offsets are different, so how will I know which offset is correct? – tacospice May 03 '17 at 09:06
  • The `LC_VERSION_MIN_IPHONEOS` load command's `00000025 00000010` sequence of bytes will appear in your framework followed by bytes corresponding to actual version. Try to find it in your binary with a hex editor. – Kamil.S May 03 '17 at 12:42
  • To find the offset you could also run your framework through `Hopper` – Kamil.S May 03 '17 at 12:49