I found a solution that will (at least temporarily) work for me - but I still encourage everyone to provide a real solution and more detailed insights.
Anyway:
Extract your binary
- Xcode Archive
- Export as IPA
- Rename
YourApp.ipa
to YourApp.zip
and extract
- Navigate to the subfolder payload to find your
YourApp.app
- Right click &
Show Package Contents
of your YourApp.app
file
- Copy your binary
YourApp
(no file extension) to a different location
Investigate your mach-o binary
- Run
otool -f
on your binary
Note the align
for both architectures are listed which, for me, says 2^14 (16384). This seems to be the threshold for the size of load commands.
- Run
otool -l
on your binary
You'll see that the different architectures and their load commands are listed - as well as their sizeofcmds
(size of commands).
Now the funny thing:
For arm64, the sizeofcmds
(16464) was larger than the align (16384), while it wasn't for armv7.
Now I haven't found enough documentation on this, but I assume that align symbolizes a threshold that should not be reached by the load command size. And also that it adjusts automatically (since we are definitely not having that many frameworks in our app, there have to be apps that have more).
So I guess the error came from this unlikely case, that the sizeofcmds
was different in between the architectures AND that one of them was actually valid (so that the align was not automatically adjusted).
Please correct me if I'm wrong, I am just assuming here and I really really want to understand why this happens.
Solve the issue
Remove frameworks until you are under the sizeofcmds
for both architectures.
I know this is not scalable, we were lucky (and stupid) that we still had one barely used framework in there that we could easily remove.
Fortunately this only seems to be an issue on iOS9 and will therefore loose relevance over the next months, nevertheless, we should find out if I'm right
Investigation ideas
My assumption that the align is automatically adjusted could be investigated by just putting in more and more frameworks to see if it actually does.
If so, adding frameworks would also solve the original issue - not nice, but at least slightly more scalable.
Sidenote
I don't feel like I shed enough light on the origins of this issue and I had a lot of assumptions.
While my solution works, I really hope you feel encouraged to investigate this as well and give a better answer.
MachOView
. You can also check my post on minimal set ofLC
s which are really required for the binary to work here: https://mcmap.net/q/819689/-what-is-required-for-a-mach-o-executable-to-load – Heirdom